src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
GzUnpackingService implements FileUnpackingService { public void unpackFile(final String zipFile, final String destinationFolder) throws CompressionExtensionNotRecognizedException, IOException { String[] extensions = CompressionFileExtension.getExtensionValues(); unpackFile(zipFile, destinationFolder, extensions); } v... | @Test public void shouldUnpackTheTarGzFilesRecursively() throws CompressionExtensionNotRecognizedException, IOException { gzUnpackingService.unpackFile(DESTINATION_DIR + FILE_NAME + ".tar.gz", DESTINATION_DIR); Collection files = getXMLFiles(DESTINATION_DIR + FILE_NAME); assertNotNull(files); assertEquals(XML_FILES_COU... |
UnpackingServiceFactory { public static FileUnpackingService createUnpackingService(String compressingExtension) throws CompressionExtensionNotRecognizedException { if (compressingExtension.equals(CompressionFileExtension.ZIP.getExtension())) return ZIP_UNPACKING_SERVICE; else if (compressingExtension.equals(Compressio... | @Test public void shouldReturnZipService() throws CompressionExtensionNotRecognizedException { FileUnpackingService fileUnpackingService = UnpackingServiceFactory.createUnpackingService(ZIP_EXTENSION); assertTrue(fileUnpackingService instanceof ZipUnpackingService); }
@Test public void shouldReturnGZipService() throws ... |
XsltBolt extends AbstractDpsBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { StringWriter writer = null; try { final String fileUrl = stormTaskTuple.getFileUrl(); final String xsltUrl = stormTaskTuple.getParameter(PluginParameterKeys.XSLT_URL); LOGGER.info("Processing file: {} wi... | @Test public void executeBolt() throws IOException { Tuple anchorTuple = mock(TupleImpl.class); StormTaskTuple tuple = new StormTaskTuple(TASK_ID, TASK_NAME, SOURCE_VERSION_URL, readMockContentOfURL(sampleXmlFileName), prepareStormTaskTupleParameters(sampleXsltFileName), new Revision()); xsltBolt.execute(anchorTuple, t... |
IndexingBolt extends AbstractDpsBolt { @Override public void execute(Tuple anchorTuple, StormTaskTuple stormTaskTuple) { final String useAltEnv = stormTaskTuple .getParameter(PluginParameterKeys.METIS_USE_ALT_INDEXING_ENV); final String datasetId = stormTaskTuple.getParameter(PluginParameterKeys.METIS_DATASET_ID); fina... | @Test public void shouldIndexFileForPreviewEnv() throws Exception { Tuple anchorTuple = mock(TupleImpl.class); String targetIndexingEnv = "PREVIEW"; StormTaskTuple tuple = mockStormTupleFor(targetIndexingEnv); mockIndexerFactoryFor(null); indexingBolt.execute(anchorTuple, tuple); Mockito.verify(outputCollector, Mockito... |
KafkaBridge { public void importTopic(String topicToImport) throws Exception { List<String> topics = availableTopics; if (StringUtils.isNotEmpty(topicToImport)) { List<String> topics_subset = new ArrayList<>(); for(String topic : topics) { if (Pattern.compile(topicToImport).matcher(topic).matches()) { topics_subset.add... | @Test public void testImportTopic() throws Exception { List<String> topics = setupTopic(zkClient, TEST_TOPIC_NAME); AtlasEntity.AtlasEntityWithExtInfo atlasEntityWithExtInfo = new AtlasEntity.AtlasEntityWithExtInfo( getTopicEntityWithGuid("0dd466a4-3838-4537-8969-6abb8b9e9185")); KafkaBridge kafkaBridge = mock(KafkaBri... |
EntitySearchProcessor extends SearchProcessor { @Override public List<AtlasVertex> execute() { if (LOG.isDebugEnabled()) { LOG.debug("==> EntitySearchProcessor.execute({})", context); } List<AtlasVertex> ret = new ArrayList<>(); AtlasPerfTracer perf = null; if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = Atl... | @Test public void ALLEntityType() throws AtlasBaseException { SearchParameters params = new SearchParameters(); params.setTypeName(SearchParameters.ALL_ENTITY_TYPES); params.setLimit(20); SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet()); EntitySearchProcessor proces... |
MetricsService { @SuppressWarnings("unchecked") @GraphTransaction public AtlasMetrics getMetrics() { final AtlasTypesDef typesDef = getTypesDef(); Collection<AtlasEntityDef> entityDefs = typesDef.getEntityDefs(); Collection<AtlasClassificationDef> classificationDefs = typesDef.getClassificationDefs(); Map<String, Long>... | @Test public void testGetMetrics() { AtlasMetrics metrics = metricsService.getMetrics(); assertNotNull(metrics); assertEquals(metrics.getNumericMetric(GENERAL, METRIC_ENTITY_COUNT).intValue(), 43); assertEquals(metrics.getNumericMetric(GENERAL, METRIC_TAG_COUNT).intValue(), 1); assertTrue(metrics.getNumericMetric(GENER... |
AtlasMapType extends AtlasType { @Override public boolean isValidValue(Object obj) { if (obj != null) { if (obj instanceof Map) { Map<Object, Objects> map = (Map<Object, Objects>) obj; for (Map.Entry e : map.entrySet()) { if (!keyType.isValidValue(e.getKey()) || !valueType.isValidValue(e.getValue())) { return false; } ... | @Test public void testMapTypeIsValidValue() { for (Object value : validValues) { assertTrue(intIntMapType.isValidValue(value), "value=" + value); } for (Object value : invalidValues) { assertFalse(intIntMapType.isValidValue(value), "value=" + value); } } |
UserProfileService { public AtlasUserProfile saveUserProfile(AtlasUserProfile profile) throws AtlasBaseException { return dataAccess.save(profile); } @Inject UserProfileService(DataAccess dataAccess); AtlasUserProfile saveUserProfile(AtlasUserProfile profile); AtlasUserProfile getUserProfile(String userName); AtlasUse... | @Test(dependsOnMethods = "filterInternalType") public void createsNewProfile() throws AtlasBaseException { for (int i = 0; i < NUM_USERS; i++) { AtlasUserProfile expected = getAtlasUserProfile(i); AtlasUserProfile actual = userProfileService.saveUserProfile(expected); assertNotNull(actual); assertEquals(expected.getNam... |
UserProfileService { public AtlasUserSavedSearch addSavedSearch(AtlasUserSavedSearch savedSearch) throws AtlasBaseException { String userName = savedSearch.getOwnerName(); AtlasUserProfile userProfile = null; try { userProfile = getUserProfile(userName); } catch (AtlasBaseException excp) { } if (userProfile == null) { ... | @Test(dependsOnMethods = "saveSearchesForUser", expectedExceptions = AtlasBaseException.class) public void attemptToAddExistingSearch() throws AtlasBaseException { String userName = getIndexBasedUserName(0); SearchParameters expectedSearchParameter = getActualSearchParameters(); for (int j = 0; j < NUM_SEARCHES; j++) {... |
UserProfileService { public List<AtlasUserSavedSearch> getSavedSearches(String userName) throws AtlasBaseException { AtlasUserProfile profile = null; try { profile = getUserProfile(userName); } catch (AtlasBaseException excp) { } return (profile != null) ? profile.getSavedSearches() : null; } @Inject UserProfileServic... | @Test(dependsOnMethods = "attemptToAddExistingSearch") public void verifySavedSearchesForUser() throws AtlasBaseException { String userName = getIndexBasedUserName(0); List<AtlasUserSavedSearch> searches = userProfileService.getSavedSearches(userName); List<String> names = getIndexBasedQueryNamesList(); for (int i = 0;... |
AtlasEntityStoreV2 implements AtlasEntityStore { @Override @GraphTransaction public EntityMutationResponse createOrUpdate(EntityStream entityStream, boolean isPartialUpdate) throws AtlasBaseException { return createOrUpdate(entityStream, isPartialUpdate, false, false); } @Inject AtlasEntityStoreV2(AtlasGraph graph, De... | @Test public void testDefaultValueForPrimitiveTypes() throws Exception { init(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(primitiveEntity), false); List<AtlasEntityHeader> entitiesCreatedResponse = response.getEntitiesByOperation(EntityOperation.CREATE); List<AtlasEntityHeader>... |
AtlasMapType extends AtlasType { @Override public Map<Object, Object> getNormalizedValue(Object obj) { if (obj == null) { return null; } if (obj instanceof String) { obj = AtlasType.fromJson(obj.toString(), Map.class); } if (obj instanceof Map) { Map<Object, Object> ret = new HashMap<>(); Map<Object, Objects> map = (Ma... | @Test public void testMapTypeGetNormalizedValue() { assertNull(intIntMapType.getNormalizedValue(null), "value=" + null); for (Object value : validValues) { if (value == null) { continue; } Map<Object, Object> normalizedValue = intIntMapType.getNormalizedValue(value); assertNotNull(normalizedValue, "value=" + value); } ... |
AtlasEntityStoreV2 implements AtlasEntityStore { @Override @GraphTransaction public void setLabels(String guid, Set<String> labels) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> setLabels()"); } if (StringUtils.isEmpty(guid)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "gu... | @Test(dependsOnMethods = "testCreate") public void addLabelsToEntity() throws AtlasBaseException { Set<String> labels = new HashSet<>(); labels.add("label_1"); labels.add("label_2"); labels.add("label_3"); labels.add("label_4"); labels.add("label_5"); entityStore.setLabels(tblEntityGuid, labels); AtlasEntity tblEntity ... |
AtlasMapType extends AtlasType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { if (obj instanceof Map) { Map<Object, Objects> map = (Map<Object, Objects>) obj; for (Map.Entry e : map.entrySet()) { Object key = e.getKey(); if (!keyType.... | @Test public void testMapTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(intIntMapType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(intIntMapType.validateV... |
AtlasEntityStoreV2 implements AtlasEntityStore { @Override @GraphTransaction public void removeLabels(String guid, Set<String> labels) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> removeLabels()"); } if (StringUtils.isEmpty(guid)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETER... | @Test (dependsOnMethods = "addMoreLabelsToEntity") public void deleteLabelsToEntity() throws AtlasBaseException { Set<String> labels = new HashSet<>(); labels.add("label_1_add"); labels.add("label_2_add"); entityStore.removeLabels(tblEntityGuid, labels); AtlasEntity tblEntity = getEntityFromStore(tblEntityGuid); assert... |
AtlasEntityStoreV2 implements AtlasEntityStore { @Override @GraphTransaction public void addOrUpdateBusinessAttributes(String guid, Map<String, Map<String, Object>> businessAttrbutes, boolean isOverwrite) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> addOrUpdateBusinessAttributes(guid={}, busin... | @Test public void testAddBusinessAttributesStringMaxLengthCheck_2() throws Exception { Map<String, Map<String, Object>> bmMapReq = new HashMap<>(); Map<String, Object> bmAttrMapReq = new HashMap<>(); bmAttrMapReq.put("attr8", "012345678901234567890"); bmMapReq.put("bmWithAllTypes", bmAttrMapReq); try { entityStore.addO... |
AtlasEntityStoreV2 implements AtlasEntityStore { @Override @GraphTransaction public BulkImportResponse bulkCreateOrUpdateBusinessAttributes(InputStream inputStream, String fileName) throws AtlasBaseException { BulkImportResponse ret = new BulkImportResponse(); try { if (StringUtils.isBlank(fileName)) { throw new AtlasB... | @Test public void testEmptyFileException() { InputStream inputStream = getFile(CSV_FILES, "empty.csv"); try { entityStore.bulkCreateOrUpdateBusinessAttributes(inputStream, "empty.csv"); fail("Error occurred : Failed to recognize the empty file."); } catch (AtlasBaseException e) { assertEquals(e.getMessage(), "No data f... |
AtlasArrayType extends AtlasType { @Override public Collection<?> createDefaultValue() { Collection<Object> ret = new ArrayList<>(); ret.add(elementType.createDefaultValue()); if (minCount != COUNT_NOT_SET) { for (int i = 1; i < minCount; i++) { ret.add(elementType.createDefaultValue()); } } return ret; } AtlasArrayTyp... | @Test public void testArrayTypeDefaultValue() { Collection defValue = intArrayType.createDefaultValue(); assertEquals(defValue.size(), 1); } |
AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassificationDef> { @Override public boolean isValidName(String typeName) { Matcher m = TRAIT_NAME_PATTERN.matcher(typeName); return m.matches(); } AtlasClassificationDefStoreV2(AtlasTypeDefGraphStoreV2 typeDefStore, AtlasTypeRegistry typeRegistry); @O... | @Test(dataProvider = "traitRegexString") public void testIsValidName(String data, boolean expected) { assertEquals(classificationDefStore.isValidName(data), expected); } |
AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRelationshipDef> { @Override public AtlasRelationshipDef create(AtlasRelationshipDef relationshipDef, AtlasVertex preCreateResult) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasRelationshipDefStoreV1.create({}, {})", relation... | @Test(dataProvider = "invalidAttributeNameWithReservedKeywords") public void testCreateTypeWithReservedKeywords(AtlasRelationshipDef atlasRelationshipDef) throws AtlasException { try { ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV2.ALLOW_RESERVED_KEYWORDS, false); relationshipDefStore.create(atlasRelat... |
AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRelationshipDef> { private void preUpdateCheck(AtlasRelationshipDef newRelationshipDef, AtlasRelationshipType relationshipType, AtlasVertex vertex) throws AtlasBaseException { AtlasRelationshipDef existingRelationshipDef = toRelationshipDef(vertex); preUp... | @Test(dataProvider = "updateValidProperties") public void testupdateVertexPreUpdatepropagateTags(AtlasRelationshipDef existingRelationshipDef,AtlasRelationshipDef newRelationshipDef) throws AtlasBaseException { AtlasRelationshipDefStoreV2.preUpdateCheck(existingRelationshipDef, newRelationshipDef); }
@Test(dataProvider... |
AtlasEntityDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasEntityDef> { @Override public AtlasEntityDef create(AtlasEntityDef entityDef, AtlasVertex preCreateResult) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasEntityDefStoreV1.create({}, {})", entityDef, preCreateResult); } verifyAttribu... | @Test(dataProvider = "invalidAttributeNameWithReservedKeywords") public void testCreateTypeWithReservedKeywords(AtlasEntityDef atlasEntityDef) throws AtlasException { try { ApplicationProperties.get().setProperty(AtlasAbstractDefStoreV2.ALLOW_RESERVED_KEYWORDS, false); entityDefStore.create(atlasEntityDef, null); } cat... |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override public AtlasTypesDef searchTypesDef(SearchFilter searchFilter) throws AtlasBaseException { final AtlasTypesDef typesDef = new AtlasTypesDef(); Predicate searchPredicates = FilterUtil.getPredicateFromSearchFilter(searchFilter); for(AtlasEnumType enumType : ... | @Test public void testGet() { try { AtlasTypesDef typesDef = typeDefStore.searchTypesDef(new SearchFilter()); assertNotNull(typesDef.getEnumDefs()); assertEquals(typesDef.getStructDefs().size(), 0); assertNotNull(typesDef.getStructDefs()); assertEquals(typesDef.getClassificationDefs().size(), 0); assertNotNull(typesDef... |
AtlasArrayType extends AtlasType { @Override public boolean isValidValue(Object obj) { if (obj != null) { if (obj instanceof List || obj instanceof Set) { Collection objList = (Collection) obj; if (!isValidElementCount(objList.size())) { return false; } for (Object element : objList) { if (!elementType.isValidValue(ele... | @Test public void testArrayTypeIsValidValue() { for (Object value : validValues) { assertTrue(intArrayType.isValidValue(value), "value=" + value); } for (Object value : invalidValues) { assertFalse(intArrayType.isValidValue(value), "value=" + value); } } |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override @GraphTransaction public AtlasTypesDef updateTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships{}... | @Test(enabled = false, dependsOnMethods = {"testCreateDept"}) public void testUpdateWithMandatoryFields(){ AtlasTypesDef atlasTypesDef = TestUtilsV2.defineInvalidUpdatedDeptEmployeeTypes(); List<AtlasEnumDef> enumDefsToUpdate = atlasTypesDef.getEnumDefs(); List<AtlasClassificationDef> classificationDefsToUpdate = atlas... |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override @GraphTransaction public void deleteTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasTypeDefGraphStore.deleteTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships={}, busine... | @Test(dependsOnMethods = {"testUpdate"}, dataProvider = "allCreatedTypes") public void testDelete(AtlasTypesDef atlasTypesDef){ try { typeDefStore.deleteTypesDef(atlasTypesDef); } catch (AtlasBaseException e) { fail("Deletion should've succeeded"); } } |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override @GraphTransaction public void deleteTypeByName(String typeName) throws AtlasBaseException { AtlasType atlasType = typeRegistry.getType(typeName); if (atlasType == null) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS.TYPE_NAME_NOT_FOUND, t... | @Test public void deleteTypeByName() throws IOException { try { final String HIVEDB_v2_JSON = "hiveDBv2"; final String hiveDB2 = "hive_db_v2"; final String relationshipDefName = "cluster_hosts_relationship"; final String hostEntityDef = "host"; final String clusterEntityDef = "cluster"; AtlasTypesDef typesDef = TestRes... |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override @GraphTransaction public AtlasTypesDef createTypesDef(AtlasTypesDef typesDef) throws AtlasBaseException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasTypeDefGraphStore.createTypesDef(enums={}, structs={}, classifications={}, entities={}, relationships=... | @Test(dependsOnMethods = "testGet") public void testCreateWithValidAttributes(){ AtlasTypesDef hiveTypes = TestUtilsV2.defineHiveTypes(); try { AtlasTypesDef createdTypes = typeDefStore.createTypesDef(hiveTypes); assertEquals(hiveTypes.getEnumDefs(), createdTypes.getEnumDefs(), "Data integrity issue while persisting");... |
AtlasArrayType extends AtlasType { @Override public Collection<?> getNormalizedValue(Object obj) { Collection<Object> ret = null; if (obj instanceof String) { obj = AtlasType.fromJson(obj.toString(), List.class); } if (obj instanceof List || obj instanceof Set) { Collection collObj = (Collection) obj; if (isValidElemen... | @Test public void testArrayTypeGetNormalizedValue() { assertNull(intArrayType.getNormalizedValue(null), "value=" + null); for (Object value : validValues) { if (value == null) { continue; } Collection normalizedValue = intArrayType.getNormalizedValue(value); assertNotNull(normalizedValue, "value=" + value); } for (Obje... |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override public AtlasEntityDef getEntityDefByName(String name) throws AtlasBaseException { AtlasEntityDef ret = typeRegistry.getEntityDefByName(name); if (ret == null) { ret = StringUtils.equals(name, ALL_ENTITY_TYPES) ? AtlasEntityType.getEntityRoot().getEntityDef... | @Test public void testGetOnAllEntityTypes() throws AtlasBaseException { AtlasEntityDef entityDefByName = typeDefStore.getEntityDefByName("_ALL_ENTITY_TYPES"); assertNotNull(entityDefByName); assertEquals(entityDefByName, AtlasEntityType.getEntityRoot().getEntityDef()); } |
AtlasTypeDefGraphStore implements AtlasTypeDefStore { @Override public AtlasClassificationDef getClassificationDefByName(String name) throws AtlasBaseException { AtlasClassificationDef ret = typeRegistry.getClassificationDefByName(name); if (ret == null) { ret = StringUtils.equalsIgnoreCase(name, ALL_CLASSIFICATION_TYP... | @Test public void testGetOnAllClassificationTypes() throws AtlasBaseException { AtlasClassificationDef classificationTypeDef = typeDefStore.getClassificationDefByName("_ALL_CLASSIFICATION_TYPES"); assertNotNull(classificationTypeDef); assertEquals(classificationTypeDef, AtlasClassificationType.getClassificationRoot().g... |
HdfsPathEntityCreator { public AtlasEntity.AtlasEntityWithExtInfo getCreateEntity(AtlasObjectId item) throws AtlasBaseException { if(item.getUniqueAttributes() == null || !item.getUniqueAttributes().containsKey(HDFS_PATH_ATTRIBUTE_NAME_PATH)) { return null; } return getCreateEntity((String) item.getUniqueAttributes().g... | @Test(dependsOnMethods = "verifyCreate") public void verifyGet() throws AtlasBaseException { AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = hdfsPathEntityCreator.getCreateEntity(expectedPath, expectedClusterName); assertNotNull(entityWithExtInfo); } |
ExportService { public AtlasExportResult run(ZipSink exportSink, AtlasExportRequest request, String userName, String hostName, String requestingIP) throws AtlasBaseException { long startTime = System.currentTimeMillis(); AtlasExportResult result = new AtlasExportResult(request, userName, requestingIP, hostName, startTi... | @Test public void exportType() throws AtlasBaseException { String requestingIP = "1.0.0.0"; String hostName = "root"; AtlasExportRequest request = getRequestForFullFetch(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ZipSink zipSink = new ZipSink(baos); AtlasExportResult result = exportService.run(zipSink... |
ExportService { @VisibleForTesting AtlasExportResult.OperationStatus getOverallOperationStatus(AtlasExportResult.OperationStatus... statuses) { AtlasExportResult.OperationStatus overall = (statuses.length == 0) ? AtlasExportResult.OperationStatus.FAIL : statuses[0]; for (AtlasExportResult.OperationStatus s : statuses) ... | @Test public void verifyOverallStatus() { assertEquals(AtlasExportResult.OperationStatus.FAIL, exportService.getOverallOperationStatus()); assertEquals(AtlasExportResult.OperationStatus.SUCCESS, exportService.getOverallOperationStatus(AtlasExportResult.OperationStatus.SUCCESS)); assertEquals(AtlasExportResult.Operation... |
ExportImportAuditService { public ExportImportAuditEntry get(ExportImportAuditEntry entry) throws AtlasBaseException { if(entry.getGuid() == null) { throw new AtlasBaseException("entity does not have GUID set. load cannot proceed."); } return dataAccess.load(entry); } @Inject ExportImportAuditService(DataAccess dataAc... | @Test public void numberOfSavedEntries_Retrieved() throws AtlasBaseException, InterruptedException { final String source1 = "server1"; final String target1 = "cly"; int MAX_ENTRIES = 5; for (int i = 0; i < MAX_ENTRIES; i++) { saveAndGet(source1, ExportImportAuditEntry.OPERATION_EXPORT, target1); } pauseForIndexCreation... |
AtlasArrayType extends AtlasType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { if (obj instanceof List || obj instanceof Set) { Collection objList = (Collection) obj; if (!isValidElementCount(objList.size())) { ret = false; messages.... | @Test public void testArrayTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(intArrayType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(intArrayType.validateV... |
ZipSource implements EntityImportStream { @Override public List<String> getCreationOrder() { return this.creationOrder; } ZipSource(InputStream inputStream); ZipSource(InputStream inputStream, ImportTransforms importTransform); @Override ImportTransforms getImportTransform(); @Override void setImportTransform(ImportTr... | @Test(expectedExceptions = AtlasBaseException.class) public void improperInit_ReturnsNullCreationOrder() throws IOException, AtlasBaseException { byte bytes[] = new byte[10]; ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ZipSource zs = new ZipSource(bais); List<String> s = zs.getCreationOrder(); Assert.a... |
ImportTransforms { public AtlasEntity.AtlasEntityWithExtInfo apply(AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo) throws AtlasBaseException { if (entityWithExtInfo == null) { return entityWithExtInfo; } apply(entityWithExtInfo.getEntity()); if(MapUtils.isNotEmpty(entityWithExtInfo.getReferredEntities())) { for (... | @Test public void transformEntityWith2Transforms() throws AtlasBaseException { AtlasEntity entity = getHiveTableAtlasEntity(); String attrValue = (String) entity.getAttribute(ATTR_NAME_QUALIFIED_NAME); transform.apply(entity); assertEquals(entity.getAttribute(ATTR_NAME_QUALIFIED_NAME), applyDefaultTransform(attrValue))... |
ImportService { public AtlasImportResult run(InputStream inputStream, String userName, String hostName, String requestingIP) throws AtlasBaseException { return run(inputStream, null, userName, hostName, requestingIP); } @Inject ImportService(AtlasTypeDefStore typeDefStore, AtlasTypeRegistry typeRegistry, BulkImporter ... | @Test public void importServiceProcessesIOException() { ImportService importService = new ImportService(typeDefStore, typeRegistry, null,null, null,null); AtlasImportRequest req = mock(AtlasImportRequest.class); Answer<Map> answer = invocationOnMock -> { throw new IOException("file is read only"); }; when(req.getFileNa... |
ImportService { @VisibleForTesting void setImportTransform(EntityImportStream source, String transforms) throws AtlasBaseException { ImportTransforms importTransform = ImportTransforms.fromJson(transforms); if (importTransform == null) { return; } importTransformsShaper.shape(importTransform, source.getExportResult().g... | @Test(dataProvider = "salesNewTypeAttrs-next") public void transformUpdatesForSubTypes(InputStream inputStream) throws IOException, AtlasBaseException { loadBaseModel(); loadHiveModel(); String transformJSON = "{ \"Asset\": { \"qualifiedName\":[ \"lowercase\", \"replace:@cl1:@cl2\" ] } }"; ZipSource zipSource = new Zip... |
ImportService { @VisibleForTesting boolean checkHiveTableIncrementalSkipLineage(AtlasImportRequest importRequest, AtlasExportRequest exportRequest) { if (exportRequest == null || CollectionUtils.isEmpty(exportRequest.getItemsToExport())) { return false; } for (AtlasObjectId itemToExport : exportRequest.getItemsToExport... | @Test public void testCheckHiveTableIncrementalSkipLineage() { AtlasImportRequest importRequest; AtlasExportRequest exportRequest; importRequest = getImportRequest("cl1"); exportRequest = getExportRequest(FETCH_TYPE_INCREMENTAL, "cl2", true, getItemsToExport("hive_table", "hive_table")); assertTrue(importService.checkH... |
StartEntityFetchByExportRequest { public List<AtlasObjectId> get(AtlasExportRequest exportRequest) { List<AtlasObjectId> list = new ArrayList<>(); for(AtlasObjectId objectId : exportRequest.getItemsToExport()) { List<String> guids = get(exportRequest, objectId); if (guids.isEmpty()) { continue; } objectId.setGuid(guids... | @Test public void fetchTypeGuid() { String exportRequestJson = "{ \"itemsToExport\": [ { \"typeName\": \"hive_db\", \"guid\": \"111-222-333\" } ]}"; AtlasExportRequest exportRequest = AtlasType.fromJson(exportRequestJson, AtlasExportRequest.class); List<AtlasObjectId> objectGuidMap = startEntityFetchByExportRequestSpy.... |
ImportTransformer { public static ImportTransformer getTransformer(String transformerSpec) throws AtlasBaseException { String[] params = StringUtils.split(transformerSpec, TRANSFORMER_PARAMETER_SEPARATOR); String key = (params == null || params.length < 1) ? transformerSpec : params[0]; final ImportTransformer ret; if ... | @Test public void createWithCorrectParameters() throws AtlasBaseException, IllegalAccessException { String param1 = "@cl1"; String param2 = "@cl2"; ImportTransformer e = ImportTransformer.getTransformer(String.format("%s:%s:%s", "replace", param1, param2)); assertTrue(e instanceof ImportTransformer.Replace); assertEqua... |
AtlasStructType extends AtlasType { @Override public AtlasStruct createDefaultValue() { AtlasStruct ret = new AtlasStruct(structDef.getName()); populateDefaultValues(ret); return ret; } AtlasStructType(AtlasStructDef structDef); AtlasStructType(AtlasStructDef structDef, AtlasTypeRegistry typeRegistry); AtlasStructDef ... | @Test public void testStructTypeDefaultValue() { AtlasStruct defValue = structType.createDefaultValue(); assertNotNull(defValue); assertEquals(defValue.getTypeName(), structType.getTypeName()); } |
AtlasAuditService { public AtlasAuditEntry get(AtlasAuditEntry entry) throws AtlasBaseException { if(entry.getGuid() == null) { throw new AtlasBaseException("Entity does not have GUID set. load cannot proceed."); } return dataAccess.load(entry); } @Inject AtlasAuditService(DataAccess dataAccess, AtlasDiscoveryService ... | @Test public void checkStoringMultipleAuditEntries() throws AtlasBaseException, InterruptedException { final String clientId = "client1"; final int MAX_ENTRIES = 5; final int LIMIT_PARAM = 3; for (int i = 0; i < MAX_ENTRIES; i++) { saveEntry(AuditOperation.PURGE, clientId); } waitForIndexCreation(); AuditSearchParamete... |
GlossaryService { @GraphTransaction public AtlasGlossary createGlossary(AtlasGlossary atlasGlossary) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.createGlossary({})", atlasGlossary); } if (Objects.isNull(atlasGlossary)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Gloss... | @Test(groups = "Glossary.CREATE") public void testCreateGlossary() { try { AtlasGlossary created = glossaryService.createGlossary(bankGlossary); bankGlossary.setGuid(created.getGuid()); created = glossaryService.createGlossary(creditUnionGlossary); creditUnionGlossary.setGuid(created.getGuid()); } catch (AtlasBaseExcep... |
GlossaryService { @GraphTransaction public AtlasGlossaryTerm createTerm(AtlasGlossaryTerm glossaryTerm) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.create({})", glossaryTerm); } if (Objects.isNull(glossaryTerm)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "GlossaryTerm... | @Test(groups = "Glossary.CREATE" , dependsOnMethods = "testCategoryCreation") public void testTermCreationWithoutAnyRelations() { try { checkingAccount = glossaryService.createTerm(checkingAccount); assertNotNull(checkingAccount); assertNotNull(checkingAccount.getGuid()); } catch (AtlasBaseException e) { fail("Term cre... |
GlossaryService { @GraphTransaction public List<AtlasGlossaryTerm> createTerms(List<AtlasGlossaryTerm> glossaryTerm) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.create({})", glossaryTerm); } if (Objects.isNull(glossaryTerm)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, ... | @Test(groups = "Glossary.CREATE" , dependsOnMethods = "testCategoryCreation") public void testTermCreationWithCategory() { try { AtlasTermCategorizationHeader termCategorizationHeader = new AtlasTermCategorizationHeader(); termCategorizationHeader.setCategoryGuid(mortgageCategory.getGuid()); termCategorizationHeader.se... |
GlossaryService { @GraphTransaction public List<AtlasGlossary> getGlossaries(int limit, int offset, SortOrder sortOrder) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.getGlossaries({}, {}, {})", limit, offset, sortOrder); } List<String> glossaryGuids = AtlasGraphUtilsV2.findEntityGUIDs... | @Test(dataProvider = "getAllGlossaryDataProvider", groups = "Glossary.GET", dependsOnGroups = "Glossary.CREATE") public void testGetAllGlossaries(int limit, int offset, SortOrder sortOrder, int expected) { try { List<AtlasGlossary> glossaries = glossaryService.getGlossaries(limit, offset, sortOrder); assertEquals(gloss... |
GlossaryService { @GraphTransaction public AtlasGlossary updateGlossary(AtlasGlossary atlasGlossary) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.updateGlossary({})", atlasGlossary); } if (Objects.isNull(atlasGlossary)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Gloss... | @Test(groups = "Glossary.UPDATE", dependsOnGroups = "Glossary.CREATE") public void testUpdateGlossary() { try { bankGlossary = glossaryService.getGlossary(bankGlossary.getGuid()); bankGlossary.setShortDescription("Updated short description"); bankGlossary.setLongDescription("Updated long description"); AtlasGlossary up... |
GlossaryService { @GraphTransaction public void deleteGlossary(String glossaryGuid) throws AtlasBaseException { if (DEBUG_ENABLED) { LOG.debug("==> GlossaryService.deleteGlossary({})", glossaryGuid); } if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/emp... | @Test(dependsOnMethods = "testInvalidFetches") public void testDeleteGlossary() { try { glossaryService.deleteGlossary(bankGlossary.getGuid()); try { glossaryService.getGlossary(bankGlossary.getGuid()); } catch (AtlasBaseException e) { assertEquals(e.getAtlasErrorCode(), AtlasErrorCode.INSTANCE_GUID_NOT_FOUND); } try {... |
AtlasStructType extends AtlasType { @Override public boolean isValidValue(Object obj) { if (obj != null) { if (obj instanceof AtlasStruct) { AtlasStruct structObj = (AtlasStruct) obj; for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { if (!isAssignableValue(structObj.getAttribute(attributeDef.getName... | @Test public void testStructTypeIsValidValue() { for (Object value : validValues) { assertTrue(structType.isValidValue(value), "value=" + value); } for (Object value : invalidValues) { assertFalse(structType.isValidValue(value), "value=" + value); } } |
GlossaryService { @GraphTransaction public List<AtlasGlossaryTerm> getGlossaryTerms(String glossaryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } if (DEBUG_ENABLED... | @Test(dataProvider = "getGlossaryTermsProvider" , groups = "Glossary.GET.postUpdate", dependsOnGroups = "Glossary.UPDATE") public void testGetGlossaryTerms(int offset, int limit, int expected) { String guid = bankGlossary.getGuid(); SortOrder sortOrder = SortOrder.ASCENDING; try { List<AtlasRelatedTermHeader> glossaryT... |
GlossaryService { @GraphTransaction public List<AtlasGlossaryCategory> getGlossaryCategories(String glossaryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(glossaryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "glossaryGuid is null/empty"); } if (DEBU... | @Test(dataProvider = "getGlossaryCategoriesProvider" , groups = "Glossary.GET.postUpdate", dependsOnGroups = "Glossary.UPDATE") public void testGetGlossaryCategories(int offset, int limit, int expected) { String guid = bankGlossary.getGuid(); SortOrder sortOrder = SortOrder.ASCENDING; try { List<AtlasRelatedCategoryHea... |
GlossaryService { @GraphTransaction public List<AtlasRelatedTermHeader> getCategoryTerms(String categoryGuid, int offset, int limit, SortOrder sortOrder) throws AtlasBaseException { if (Objects.isNull(categoryGuid)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "categoryGuid is null/empty"); } if (DEBUG_EN... | @Test(dataProvider = "getCategoryTermsProvider", dependsOnGroups = "Glossary.CREATE") public void testGetCategoryTerms(int offset, int limit, int expected) { for (AtlasGlossaryCategory c : Arrays.asList(accountCategory, mortgageCategory)) { try { List<AtlasRelatedTermHeader> categoryTerms = glossaryService.getCategoryT... |
GlossaryService { public List<AtlasGlossaryTerm> importGlossaryData(InputStream inputStream, String fileName) throws AtlasBaseException { List<AtlasGlossaryTerm> ret; try { if (StringUtils.isBlank(fileName)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_FILE_TYPE, fileName); } List<String[]> fileData = FileUtil... | @Test( dependsOnGroups = "Glossary.CREATE" ) public void testImportGlossaryData(){ try { InputStream inputStream = getFile(CSV_FILES,"template_1.csv"); List<AtlasGlossaryTerm> atlasGlossaryTermList = glossaryService.importGlossaryData(inputStream,"template_1.csv"); assertNotNull(atlasGlossaryTermList); assertEquals(atl... |
AtlasStructType extends AtlasType { @Override public Object getNormalizedValue(Object obj) { Object ret = null; if (obj != null) { if (isValidValue(obj)) { if (obj instanceof AtlasStruct) { normalizeAttributeValues((AtlasStruct) obj); ret = obj; } else if (obj instanceof Map) { normalizeAttributeValues((Map) obj); ret ... | @Test public void testStructTypeGetNormalizedValue() { assertNull(structType.getNormalizedValue(null), "value=" + null); for (Object value : validValues) { if (value == null) { continue; } Object normalizedValue = structType.getNormalizedValue(value); assertNotNull(normalizedValue, "value=" + value); } for (Object valu... |
HiveMetaStoreBridge { @VisibleForTesting public void importHiveMetadata(String databaseToImport, String tableToImport, boolean failOnError) throws Exception { LOG.info("Importing Hive metadata"); importDatabases(failOnError, databaseToImport, tableToImport); } HiveMetaStoreBridge(Configuration atlasProperties, HiveConf... | @Test public void testImportThatUpdatesRegisteredDatabase() throws Exception { when(hiveClient.getAllDatabases()).thenReturn(Arrays.asList(new String[]{TEST_DB_NAME})); String description = "This is a default database"; Database db = new Database(TEST_DB_NAME, description, "/user/hive/default", null); when(hiveClient.g... |
HAConfiguration { public static ZookeeperProperties getZookeeperProperties(Configuration configuration) { String[] zkServers; if (configuration.containsKey(HA_ZOOKEEPER_CONNECT)) { zkServers = configuration.getStringArray(HA_ZOOKEEPER_CONNECT); } else { zkServers = configuration.getStringArray("atlas.kafka." + ZOOKEEPE... | @Test public void testShouldGetZookeeperAcl() { when(configuration.getString(HAConfiguration.HA_ZOOKEEPER_ACL)).thenReturn("sasl:myclient@EXAMPLE.COM"); HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration); assertTrue(zookeeperProperties.hasAcl()); }
@Test publ... |
AtlasPathExtractorUtil { public static AtlasEntityWithExtInfo getPathEntity(Path path, PathExtractorContext context) { AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(); AtlasEntity ret; String strPath = path.toString(); if (context.isConvertPathToLowerCase()) { strPath = strPath.toLowerCase(); } ... | @Test(dataProvider = "ozonePathProvider") public void testGetPathEntityOzone3Path(OzoneKeyValidator validator) { String scheme = validator.scheme; String ozonePath = scheme + validator.location; PathExtractorContext extractorContext = new PathExtractorContext(METADATA_NAMESPACE); Path path = new Path(ozonePath); AtlasE... |
AtlasStructType extends AtlasType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { if (obj instanceof AtlasStruct) { AtlasStruct structObj = (AtlasStruct) obj; for (AtlasAttributeDef attributeDef : structDef.getAttributeDefs()) { String... | @Test public void testStructTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(structType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(structType.validateValu... |
AtlasClientV2 extends AtlasBaseClient { public void updateClassifications(String guid, List<AtlasClassification> classifications) throws AtlasServiceException { callAPI(formatPathParameters(API_V2.UPDATE_CLASSIFICATIONS, guid), (Class<?>)null, classifications); } AtlasClientV2(String[] baseUrl, String[] basicAuthUserNa... | @Test public void updateClassificationsShouldNotThrowExceptionIfResponseIs204() { AtlasClientV2 atlasClient = new AtlasClientV2(service, configuration); AtlasClassification atlasClassification = new AtlasClassification("Testdb"); atlasClassification.setEntityGuid("abb672b1-e4bd-402d-a98f-73cd8f775e2a"); WebResource.Bui... |
AtlasClient extends AtlasBaseClient { public Referenceable getEntity(String guid) throws AtlasServiceException { ObjectNode jsonResponse = callAPIWithBodyAndParams(API_V1.GET_ENTITY, null, guid); String entityInstanceDefinition = AtlasType.toJson(jsonResponse.get(AtlasClient.DEFINITION)); return AtlasType.fromV1Json(en... | @Test public void shouldVerifyServerIsReady() throws AtlasServiceException { setupRetryParams(); AtlasClient atlasClient = new AtlasClient(service, configuration); WebResource.Builder builder = setupBuilder(AtlasClient.API_V1.VERSION, service); ClientResponse response = mock(ClientResponse.class); when(response.getStat... |
AtlasClient extends AtlasBaseClient { protected List<String> createEntity(ArrayNode entities) throws AtlasServiceException { LOG.debug("Creating entities: {}", entities); ObjectNode response = callAPIWithBody(API_V1.CREATE_ENTITY, entities.toString()); List<String> results = extractEntityResult(response).getCreatedEnti... | @Test public void testCreateEntity() throws Exception { setupRetryParams(); AtlasClient atlasClient = new AtlasClient(service, configuration); WebResource.Builder builder = setupBuilder(AtlasClient.API_V1.CREATE_ENTITY, service); ClientResponse response = mock(ClientResponse.class); when(response.getStatus()).thenRetur... |
AtlasEntityType extends AtlasStructType { @Override public AtlasEntity createDefaultValue() { AtlasEntity ret = new AtlasEntity(entityDef.getName()); populateDefaultValues(ret); return ret; } AtlasEntityType(AtlasEntityDef entityDef); AtlasEntityType(AtlasEntityDef entityDef, AtlasTypeRegistry typeRegistry); AtlasEnti... | @Test public void testEntityTypeDefaultValue() { AtlasEntity defValue = entityType.createDefaultValue(); assertNotNull(defValue); assertEquals(defValue.getTypeName(), entityType.getTypeName()); } |
AtlasHook { @VisibleForTesting static void notifyEntitiesInternal(List<HookNotification> messages, int maxRetries, UserGroupInformation ugi, NotificationInterface notificationInterface, boolean shouldLogFailedMessages, FailedMessagesLogger logger) { if (messages == null || messages.isEmpty()) { return; } final int maxA... | @Test (timeOut = 10000) public void testNotifyEntitiesDoesNotHangOnException() throws Exception { List<HookNotification> hookNotifications = new ArrayList<>(); doThrow(new NotificationException(new Exception())).when(notificationInterface) .send(NotificationInterface.NotificationType.HOOK, hookNotifications); AtlasHook... |
AtlasEntityType extends AtlasStructType { @Override public boolean isValidValue(Object obj) { if (obj != null) { for (AtlasEntityType superType : superTypes) { if (!superType.isValidValue(obj)) { return false; } } return super.isValidValue(obj) && validateRelationshipAttributes(obj); } return true; } AtlasEntityType(At... | @Test public void testEntityTypeIsValidValue() { for (Object value : validValues) { assertTrue(entityType.isValidValue(value), "value=" + value); } for (Object value : invalidValues) { assertFalse(entityType.isValidValue(value), "value=" + value); } } |
AtlasSimpleAuthorizer implements AtlasAuthorizer { @Override public boolean isAccessAllowed(AtlasAdminAccessRequest request) throws AtlasAuthorizationException { if (LOG.isDebugEnabled()) { LOG.debug("==> SimpleAtlasAuthorizer.isAccessAllowed({})", request); } boolean ret = false; Set<String> roles = getRoles(request.g... | @Test(enabled = true) public void testAccessAllowedForUserAndGroup() { try { AtlasEntityAccessRequest request = new AtlasEntityAccessRequest(null, AtlasPrivilege.ENTITY_UPDATE); request.setUser("admin", Collections.singleton("ROLE_ADMIN")); boolean isAccessAllowed = authorizer.isAccessAllowed(request); AssertJUnit.asse... |
AtlasEntityType extends AtlasStructType { @Override public Object getNormalizedValue(Object obj) { Object ret = null; if (obj != null) { if (isValidValue(obj)) { if (obj instanceof AtlasEntity) { normalizeAttributeValues((AtlasEntity) obj); ret = obj; } else if (obj instanceof Map) { normalizeAttributeValues((Map) obj)... | @Test public void testEntityTypeGetNormalizedValue() { assertNull(entityType.getNormalizedValue(null), "value=" + null); for (Object value : validValues) { if (value == null) { continue; } Object normalizedValue = entityType.getNormalizedValue(value); assertNotNull(normalizedValue, "value=" + value); } for (Object valu... |
AtlasJanusGraphIndexClient implements AtlasGraphIndexClient { @VisibleForTesting static List<String> getTopTerms(Map<String, TermFreq> termsMap) { final List<String> ret; if (MapUtils.isNotEmpty(termsMap)) { PriorityQueue<TermFreq> termsQueue = new PriorityQueue(termsMap.size(), FREQ_COMPARATOR); for (TermFreq term : t... | @Test public void testGetTopTermsAsendingInput() { Map<String, AtlasJanusGraphIndexClient.TermFreq> terms = generateTerms( 10, 12, 15); List<String> top5Terms = AtlasJanusGraphIndexClient.getTopTerms(terms); assertOrder(top5Terms, 2,1,0); }
@Test public void testGetTopTermsAsendingInput2() { Map<String, AtlasJanusGraph... |
AtlasJanusGraphIndexClient implements AtlasGraphIndexClient { @VisibleForTesting protected static String generateSuggestionsString(List<String> suggestionIndexFieldNames) { StringBuilder ret = new StringBuilder(); Iterator<String> iterator = suggestionIndexFieldNames.iterator(); while(iterator.hasNext()) { ret.append("... | @Test public void testGenerateSuggestionString() { List<String> fields = new ArrayList<>(); fields.add("one"); fields.add("two"); fields.add("three"); String generatedString = AtlasJanusGraphIndexClient.generateSuggestionsString(fields); Assert.assertEquals(generatedString, "'one', 'two', 'three'"); } |
AtlasEntityType extends AtlasStructType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { if (obj instanceof AtlasEntity || obj instanceof Map) { for (AtlasEntityType superType : superTypes) { ret = superType.validateValue(obj, objName, ... | @Test public void testEntityTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(entityType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(entityType.validateValu... |
AtlasJanusGraphIndexClient implements AtlasGraphIndexClient { @VisibleForTesting protected static String generateSearchWeightString(Map<String, Integer> indexFieldName2SearchWeightMap) { StringBuilder searchWeightBuilder = new StringBuilder(); for (Map.Entry<String, Integer> entry : indexFieldName2SearchWeightMap.entry... | @Test public void testGenerateSearchWeightString() { Map<String, Integer> fields = new HashMap<>(); fields.put("one", 10); fields.put("two", 1); fields.put("three", 15); String generatedString = AtlasJanusGraphIndexClient.generateSearchWeightString(fields); Assert.assertEquals(generatedString, " one^10 two^1 three^15")... |
MappedElementCache { public Vertex getMappedVertex(Graph gr, Object key) { try { Vertex ret = lruVertexCache.get(key); if (ret == null) { synchronized (lruVertexCache) { ret = lruVertexCache.get(key); if(ret == null) { ret = fetchVertex(gr, key); lruVertexCache.put(key, ret); } } } return ret; } catch (Exception ex) { ... | @Test public void vertexFetch() { JsonNode node = getCol1(); MappedElementCache cache = new MappedElementCache(); TinkerGraph tg = TinkerGraph.open(); addVertex(tg, node); Vertex vx = cache.getMappedVertex(tg, 98336); assertNotNull(vx); assertEquals(cache.lruVertexCache.size(), 1); } |
GraphSONUtility { static Object getTypedValueFromJsonNode(final JsonNode node) { Object theValue = null; if (node != null && !node.isNull()) { if (node.isBoolean()) { theValue = node.booleanValue(); } else if (node.isDouble()) { theValue = node.doubleValue(); } else if (node.isFloatingPointNumber()) { theValue = node.f... | @Test public void idFetch() { JsonNode node = getCol1(); final int EXPECTED_ID = 98336; Object o = GraphSONUtility.getTypedValueFromJsonNode(node.get(GraphSONTokensTP2._ID)); assertNotNull(o); assertEquals((int) o, EXPECTED_ID); } |
GraphSONUtility { static Map<String, Object> readProperties(final JsonNode node) { final Map<String, Object> map = new HashMap<>(); final Iterator<Map.Entry<String, JsonNode>> iterator = node.fields(); while (iterator.hasNext()) { final Map.Entry<String, JsonNode> entry = iterator.next(); if (!isReservedKey(entry.getKe... | @Test public void verifyReadProperties() { JsonNode node = getCol1(); Map<String, Object> props = GraphSONUtility.readProperties(node); assertEquals(props.get("__superTypeNames").getClass(), ArrayList.class); assertEquals(props.get("Asset.name").getClass(), String.class); assertEquals(props.get("hive_column.position").... |
GraphSONUtility { public Map<String, Object> vertexFromJson(Graph g, final JsonNode json) { final Map<String, Object> props = readProperties(json); if (props.containsKey(Constants.TYPENAME_PROPERTY_KEY)) { return null; } Map<String, Object> schemaUpdate = null; VertexFeatures vertexFeatures = g.features().vertex(); Obj... | @Test public void dataNodeReadAndVertexAddedToGraph() { JsonNode entityNode = getCol1(); TinkerGraph tg = TinkerGraph.open(); GraphSONUtility gu = new GraphSONUtility(emptyRelationshipCache); Map<String, Object> map = gu.vertexFromJson(tg, entityNode); assertNull(map); assertEquals((long) tg.traversal().V().count().nex... |
AtlasSolrQueryBuilder { public String build() throws AtlasBaseException { StringBuilder queryBuilder = new StringBuilder(); boolean isAndNeeded = false; if (queryString != null ) { if (LOG.isDebugEnabled()) { LOG.debug("Initial query string is {}.", queryString); } queryBuilder.append("+").append(queryString.trim()).ap... | @Test public void testGenerateSolrQueryString() throws IOException, AtlasBaseException { final String fileName = "src/test/resources/searchparameters2OR.json"; AtlasSolrQueryBuilder underTest = new AtlasSolrQueryBuilder(); processSearchParameters(fileName, underTest); Assert.assertEquals(underTest.build(), "+t AND -__s... |
AtlasEntityType extends AtlasStructType { private List<AtlasAttribute> reorderDynAttributes() { Map<AtlasAttribute, List<AtlasAttribute>> adj = createTokenAttributesMap(); return topologicalSort(adj); } AtlasEntityType(AtlasEntityDef entityDef); AtlasEntityType(AtlasEntityDef entityDef, AtlasTypeRegistry typeRegistry)... | @Test public void testReorderDynAttributes() { AtlasTypeRegistry typeRegistry = new AtlasTypeRegistry(); AtlasTransientTypeRegistry ttr = null; boolean commit = false; List<AtlasEntityDef> entityDefs = new ArrayList<>(); String failureMsg = null; entityDefs.add(createTableEntityDefForTopSort()); try { ttr = typeRegistr... |
ApplicationProperties extends PropertiesConfiguration { public static InputStream getFileAsInputStream(Configuration configuration, String propertyName, String defaultFileName) throws AtlasException { File fileToLoad = null; String fileName = configuration.getString(propertyName); if (fileName == null) { if (defaultFil... | @Test public void testGetFileAsInputStream() throws Exception { Configuration props = ApplicationProperties.get("test.properties"); InputStream inStr = null; try { inStr = ApplicationProperties.getFileAsInputStream(props, "jaas.properties.file", null); assertNotNull(inStr); } finally { if (inStr != null) { inStr.close(... |
AtlasRelationshipType extends AtlasStructType { public static void validateAtlasRelationshipDef(AtlasRelationshipDef relationshipDef) throws AtlasBaseException { AtlasRelationshipEndDef endDef1 = relationshipDef.getEndDef1(); AtlasRelationshipEndDef endDef2 = relationshipDef.getEndDef2(); RelationshipCategory relations... | @Test public void testvalidateAtlasRelationshipDef() throws AtlasBaseException { AtlasRelationshipEndDef ep_single = new AtlasRelationshipEndDef("typeA", "attr1", Cardinality.SINGLE); AtlasRelationshipEndDef ep_single_container = new AtlasRelationshipEndDef("typeB", "attr2", Cardinality.SINGLE); AtlasRelationshipEndDef... |
FixedBufferList { public List<T> toList() { return this.buffer.subList(0, this.length); } FixedBufferList(Class<T> clazz); FixedBufferList(Class<T> clazz, int incrementCapacityBy); T next(); List<T> toList(); void reset(); } | @Test public void createdBasedOnInitialSize() { Spying.resetCounters(); int incrementByFactor = 2; SpyingFixedBufferList fixedBufferList = new SpyingFixedBufferList(incrementByFactor); addElements(fixedBufferList, 0, 3); List<Spying> list = fixedBufferList.toList(); assertSpyingList(list, 3); assertEquals(Spying.callsT... |
NotificationEntityChangeListener implements EntityChangeListener { @VisibleForTesting public static List<Struct> getAllTraits(Referenceable entityDefinition, AtlasTypeRegistry typeRegistry) throws AtlasException { List<Struct> ret = new ArrayList<>(); for (String traitName : entityDefinition.getTraitNames()) { Struct t... | @Test public void testGetAllTraitsSuperTraits() throws Exception { AtlasTypeRegistry typeSystem = mock(AtlasTypeRegistry.class); String traitName = "MyTrait"; Struct myTrait = new Struct(traitName); String superTraitName = "MySuperTrait"; AtlasClassificationType traitDef = mock(AtlasClassificationType.class); Set<Strin... |
NotificationHookConsumer implements Service, ActiveStateChangeHandler { void startInternal(Configuration configuration, ExecutorService executorService) { if (consumers == null) { consumers = new ArrayList<>(); } if (executorService != null) { executors = executorService; } if (!HAConfiguration.isHAEnabled(configuratio... | @Test public void testConsumersStartedIfHAIsDisabled() throws Exception { List<NotificationConsumer<Object>> consumers = new ArrayList(); NotificationConsumer notificationConsumerMock = mock(NotificationConsumer.class); consumers.add(notificationConsumerMock); when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_... |
AdminResource { @GET @Path("status") @Produces(Servlets.JSON_MEDIA_TYPE) public Response getStatus() { if (LOG.isDebugEnabled()) { LOG.debug("==> AdminResource.getStatus()"); } Map<String, Object> responseData = new HashMap() {{ put(AtlasClient.STATUS, serviceState.getState().toString()); }}; if(serviceState.isInstance... | @Test public void testStatusOfActiveServerIsReturned() throws IOException { when(serviceState.getState()).thenReturn(ServiceState.ServiceStateValue.ACTIVE); AdminResource adminResource = new AdminResource(serviceState, null, null, null, null, null, null, null, null, null, null, null, null); Response response = adminRes... |
ActiveInstanceElectorService implements Service, LeaderLatchListener { @Override public void start() throws AtlasException { metricsUtil.onServerStart(); if (!HAConfiguration.isHAEnabled(configuration)) { metricsUtil.onServerActivation(); LOG.info("HA is not enabled, no need to start leader election service"); return; ... | @Test public void testLeaderElectionIsJoinedOnStart() throws Exception { when(configuration.containsKey(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true); when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY)).thenReturn(true); when(configuration.getStringArray(HAConfiguration.ATLAS_SE... |
AtlasClassificationType extends AtlasStructType { @Override public AtlasClassification createDefaultValue() { AtlasClassification ret = new AtlasClassification(classificationDef.getName()); populateDefaultValues(ret); return ret; } AtlasClassificationType(AtlasClassificationDef classificationDef); AtlasClassificationT... | @Test public void testClassificationTypeDefaultValue() { AtlasClassification defValue = classificationType.createDefaultValue(); assertNotNull(defValue); assertEquals(defValue.getTypeName(), classificationType.getTypeName()); } |
ActiveInstanceElectorService implements Service, LeaderLatchListener { @Override public void stop() { if (!HAConfiguration.isHAEnabled(configuration)) { LOG.info("HA is not enabled, no need to stop leader election service"); return; } try { leaderLatch.close(); curatorFactory.close(); } catch (IOException e) { LOG.erro... | @Test public void testNoActionOnStopIfHAModeIsDisabled() { when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(false); ActiveInstanceElectorService activeInstanceElectorService = new ActiveInstanceElectorService(configuration, new HashSet<ActiveStateChangeHandler>(), curatorFac... |
ActiveInstanceElectorService implements Service, LeaderLatchListener { @Override public void isLeader() { LOG.warn("Server instance with server id {} is elected as leader", serverId); serviceState.becomingActive(); try { for (ActiveStateChangeHandler handler : activeStateChangeHandlers) { handler.instanceIsActive(); } ... | @Test public void testActiveStateSetOnBecomingLeader() { ActiveInstanceElectorService activeInstanceElectorService = new ActiveInstanceElectorService(configuration, new HashSet<ActiveStateChangeHandler>(), curatorFactory, activeInstanceState, serviceState, metricsUtil); activeInstanceElectorService.isLeader(); InOrder ... |
ActiveInstanceElectorService implements Service, LeaderLatchListener { @Override public void notLeader() { LOG.warn("Server instance with server id {} is removed as leader", serverId); serviceState.becomingPassive(); for (int idx = activeStateChangeHandlers.size() - 1; idx >= 0; idx--) { try { activeStateChangeHandlers... | @Test public void testPassiveStateSetOnLoosingLeadership() { ActiveInstanceElectorService activeInstanceElectorService = new ActiveInstanceElectorService(configuration, new HashSet<ActiveStateChangeHandler>(), curatorFactory, activeInstanceState, serviceState, metricsUtil); activeInstanceElectorService.notLeader(); InO... |
AtlasClassificationType extends AtlasStructType { public boolean canApplyToEntityType(AtlasEntityType entityType) { return CollectionUtils.isEmpty(this.entityTypes) || this.entityTypes.contains(entityType.getTypeName()); } AtlasClassificationType(AtlasClassificationDef classificationDef); AtlasClassificationType(Atlas... | @Test public void testcanApplyToEntityType() throws AtlasBaseException { AtlasEntityDef entityDefA = new AtlasEntityDef("EntityA"); AtlasEntityDef entityDefB = new AtlasEntityDef("EntityB"); AtlasEntityDef entityDefC = new AtlasEntityDef("EntityC", null, null, null, new HashSet<>(Arrays.asList(entityDefA.getName()))); ... |
ServiceState { public ServiceStateValue getState() { return state; } ServiceState(); ServiceState(Configuration configuration); ServiceStateValue getState(); void becomingActive(); void setActive(); void becomingPassive(); void setPassive(); boolean isInstanceInTransition(); void setMigration(); boolean isInstanceInMi... | @Test public void testShouldBeActiveIfHAIsDisabled() { when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(false); ServiceState serviceState = new ServiceState(configuration); assertEquals(ServiceState.ServiceStateValue.ACTIVE, serviceState.getState()); } |
ServiceState { public void becomingPassive() { LOG.warn("Instance becoming passive from {}", state); setState(ServiceStateValue.BECOMING_PASSIVE); } ServiceState(); ServiceState(Configuration configuration); ServiceStateValue getState(); void becomingActive(); void setActive(); void becomingPassive(); void setPassive(... | @Test(expectedExceptions = IllegalStateException.class) public void testShouldDisallowTransitionIfHAIsDisabled() { when(configuration.getBoolean(HAConfiguration.ATLAS_SERVER_HA_ENABLED_KEY, false)).thenReturn(false); ServiceState serviceState = new ServiceState(configuration); serviceState.becomingPassive(); fail("Shou... |
ActiveInstanceState { public void update(String serverId) throws AtlasBaseException { try { CuratorFramework client = curatorFactory.clientInstance(); HAConfiguration.ZookeeperProperties zookeeperProperties = HAConfiguration.getZookeeperProperties(configuration); String atlasServerAddress = HAConfiguration.getBoundAddr... | @Test public void testSharedPathIsCreatedIfNotExists() throws Exception { when(configuration.getString(HAConfiguration.ATLAS_SERVER_ADDRESS_PREFIX +"id1")).thenReturn(HOST_PORT); when(configuration.getString( HAConfiguration.ATLAS_SERVER_HA_ZK_ROOT_KEY, HAConfiguration.ATLAS_SERVER_ZK_ROOT_DEFAULT)). thenReturn(HAConfi... |
ActiveServerFilter implements Filter { @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { if (isFilteredURI(servletRequest)) { LOG.debug("Is a filtered URI: {}. Passing request downstream.", ((HttpServletRequest)... | @Test public void testShouldPassThroughRequestsIfActive() throws IOException, ServletException { when(serviceState.getState()).thenReturn(ServiceState.ServiceStateValue.ACTIVE); when(servletRequest.getRequestURI()).thenReturn("api/atlas/types"); ActiveServerFilter activeServerFilter = new ActiveServerFilter(activeInsta... |
AtlasClassificationType extends AtlasStructType { @Override public boolean isValidValue(Object obj) { if (obj != null) { for (AtlasClassificationType superType : superTypes) { if (!superType.isValidValue(obj)) { return false; } } if (!validateTimeBoundaries(obj, null)) { return false; } return super.isValidValue(obj); ... | @Test public void testClassificationTypeIsValidValue() { for (Object value : validValues) { assertTrue(classificationType.isValidValue(value), "value=" + value); } for (Object value : invalidValues) { assertFalse(classificationType.isValidValue(value), "value=" + value); } } |
AtlasCSRFPreventionFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpServletResponse httpResponse = (HttpServletResponse) response; Atl... | @Test public void testNoHeaderDefaultConfig_badRequest() throws ServletException, IOException { HttpServletRequest mockReq = Mockito.mock(HttpServletRequest.class); Mockito.when(mockReq.getHeader(AtlasCSRFPreventionFilter.HEADER_DEFAULT)).thenReturn(null); Mockito.when(mockReq.getHeader(AtlasCSRFPreventionFilter.HEADER... |
AtlasClassificationType extends AtlasStructType { @Override public Object getNormalizedValue(Object obj) { Object ret = null; if (obj != null) { if (isValidValue(obj)) { if (obj instanceof AtlasClassification) { normalizeAttributeValues((AtlasClassification) obj); ret = obj; } else if (obj instanceof Map) { normalizeAt... | @Test public void testClassificationTypeGetNormalizedValue() { assertNull(classificationType.getNormalizedValue(null), "value=" + null); for (Object value : validValues) { if (value == null) { continue; } Object normalizedValue = classificationType.getNormalizedValue(value); assertNotNull(normalizedValue, "value=" + va... |
AuditFilter implements Filter { boolean isOperationExcludedFromAudit(String requestHttpMethod, String requestOperation, Configuration config) { try { return AtlasRepositoryConfiguration.isExcludedFromAudit(config, requestHttpMethod, requestOperation); } catch (AtlasException e) { return false; } } @Override void init(... | @Test public void testVerifyExcludedOperations() { AtlasRepositoryConfiguration.resetExcludedOperations(); when(configuration.getStringArray(AtlasRepositoryConfiguration.AUDIT_EXCLUDED_OPERATIONS)).thenReturn(new String[]{"GET:Version", "GET:Ping"}); AuditFilter auditFilter = new AuditFilter(); assertTrue(auditFilter.i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.