Java Code Examples for org.apache.atlas.model.instance.EntityMutationResponse#getFirstEntityCreated()
The following examples show how to use
org.apache.atlas.model.instance.EntityMutationResponse#getFirstEntityCreated() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AtlasDeleteHandlerV1Test.java From incubator-atlas with Apache License 2.0 | 5 votes |
@Test public void testDeleteAndCreate() throws Exception { init(); final AtlasEntity dbEntity = TestUtilsV2.createDBEntity(); EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(dbEntity), false); init(); //delete entity should mark it as deleted EntityMutationResponse deleteResponse = entityStore.deleteById(response.getFirstEntityCreated().getGuid()); AtlasEntityHeader dbEntityCreated = response.getFirstEntityCreated(); assertEquals(deleteResponse.getEntitiesByOperation(EntityMutations.EntityOperation.DELETE).get(0).getGuid(), dbEntityCreated.getGuid()); //get entity by unique attribute should throw EntityNotFoundException try { metadataService.getEntityDefinition(TestUtils.DATABASE_TYPE, "name", (String) response.getFirstEntityCreated().getAttribute("name")); fail("Expected EntityNotFoundException"); } catch(EntityNotFoundException e) { //expected } init(); //Create the same entity again, should create new entity AtlasEntity newDBEntity = TestUtilsV2.createDBEntity((String) dbEntity.getAttribute(NAME)); EntityMutationResponse newCreationResponse = entityStore.createOrUpdate(new AtlasEntityStream(newDBEntity), false); assertNotEquals(newCreationResponse.getFirstEntityCreated().getGuid(), response.getFirstEntityCreated().getGuid()); //get by unique attribute should return the new entity ITypedReferenceableInstance instance = metadataService.getEntityDefinitionReference(TestUtils.DATABASE_TYPE, "name", (String) dbEntity.getAttribute("name")); assertEquals(instance.getId()._getId(), newCreationResponse.getFirstEntityCreated().getGuid()); }
Example 2
Source File: AtlasEntityStoreV2Test.java From atlas with Apache License 2.0 | 4 votes |
@Test(enabled = false) //Titan doesn't allow some reserved chars in property keys. Verify that atlas encodes these //See GraphHelper.encodePropertyKey() //TODO : Failing in typedef creation public void testSpecialCharacters() throws Exception { //Verify that type can be created with reserved characters in typename, attribute name final String typeName = TestUtilsV2.randomString(10); String strAttrName = randomStrWithReservedChars(); String arrayAttrName = randomStrWithReservedChars(); String mapAttrName = randomStrWithReservedChars(); AtlasEntityDef typeDefinition = AtlasTypeUtil.createClassTypeDef(typeName, "Special chars test type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef(strAttrName, "string"), AtlasTypeUtil.createOptionalAttrDef(arrayAttrName, "array<string>"), AtlasTypeUtil.createOptionalAttrDef(mapAttrName, "map<string,string>")); AtlasTypesDef atlasTypesDef = new AtlasTypesDef(null, null, null, Arrays.asList(typeDefinition)); typeDefStore.createTypesDef(atlasTypesDef); //verify that entity can be created with reserved characters in string value, array value and map key and value AtlasEntity entity = new AtlasEntity(); entity.setAttribute(strAttrName, randomStrWithReservedChars()); entity.setAttribute(arrayAttrName, new String[]{randomStrWithReservedChars()}); entity.setAttribute(mapAttrName, new HashMap<String, String>() {{ put(randomStrWithReservedChars(), randomStrWithReservedChars()); }}); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity); final EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(entityWithExtInfo), false); final AtlasEntityHeader firstEntityCreated = response.getFirstEntityCreated(); validateEntity(entityWithExtInfo, getEntityFromStore(firstEntityCreated)); //Verify that search with reserved characters works - for string attribute // String query = // String.format("`%s` where `%s` = '%s'", typeName, strAttrName, entity.getAttribute(strAttrName)); // String responseJson = discoveryService.searchByDSL(query, new QueryParams(1, 0)); // JSONObject response = new JSONObject(responseJson); // assertEquals(response.getJSONArray("rows").length(), 1); }
Example 3
Source File: AtlasEntityStoreV1Test.java From incubator-atlas with Apache License 2.0 | 4 votes |
@Test(enabled = false) //Titan doesn't allow some reserved chars in property keys. Verify that atlas encodes these //See GraphHelper.encodePropertyKey() //TODO : Failing in typedef creation public void testSpecialCharacters() throws Exception { //Verify that type can be created with reserved characters in typename, attribute name final String typeName = "test_type_"+ RandomStringUtils.randomAlphanumeric(10); String strAttrName = randomStrWithReservedChars(); String arrayAttrName = randomStrWithReservedChars(); String mapAttrName = randomStrWithReservedChars(); AtlasEntityDef typeDefinition = AtlasTypeUtil.createClassTypeDef(typeName, "Special chars test type", ImmutableSet.<String>of(), AtlasTypeUtil.createOptionalAttrDef(strAttrName, "string"), AtlasTypeUtil.createOptionalAttrDef(arrayAttrName, "array<string>"), AtlasTypeUtil.createOptionalAttrDef(mapAttrName, "map<string,string>")); AtlasTypesDef atlasTypesDef = new AtlasTypesDef(null, null, null, Arrays.asList(typeDefinition)); typeDefStore.createTypesDef(atlasTypesDef); //verify that entity can be created with reserved characters in string value, array value and map key and value AtlasEntity entity = new AtlasEntity(); entity.setAttribute(strAttrName, randomStrWithReservedChars()); entity.setAttribute(arrayAttrName, new String[]{randomStrWithReservedChars()}); entity.setAttribute(mapAttrName, new HashMap<String, String>() {{ put(randomStrWithReservedChars(), randomStrWithReservedChars()); }}); AtlasEntityWithExtInfo entityWithExtInfo = new AtlasEntityWithExtInfo(entity); final EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(entityWithExtInfo), false); final AtlasEntityHeader firstEntityCreated = response.getFirstEntityCreated(); validateEntity(entityWithExtInfo, getEntityFromStore(firstEntityCreated)); //Verify that search with reserved characters works - for string attribute // String query = // String.format("`%s` where `%s` = '%s'", typeName, strAttrName, entity.getAttribute(strAttrName)); // String responseJson = discoveryService.searchByDSL(query, new QueryParams(1, 0)); // JSONObject response = new JSONObject(responseJson); // assertEquals(response.getJSONArray("rows").length(), 1); }