use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class EntityNotificationTest method testGetAllTraits.
@Test
public void testGetAllTraits() throws Exception {
Referenceable entity = getEntity("id");
String traitName = "MyTrait";
List<Struct> traitInfo = Collections.singletonList(new Struct(traitName, Collections.<String, Object>emptyMap()));
EntityNotificationV1 entityNotification = new EntityNotificationV1(entity, OperationType.TRAIT_ADD, traitInfo);
assertEquals(traitInfo, entityNotification.getAllTraits());
}
use of org.apache.atlas.v1.model.instance.Id in project atlas by apache.
the class HookNotificationTest method testBackwardCompatibility.
@Test
public void testBackwardCompatibility() throws Exception {
// Code to generate the json, use it for hard-coded json used later in this test
Referenceable entity = new Referenceable("sometype");
entity.set("attr", "value");
EntityCreateRequest request = new EntityCreateRequest(null, entity);
String notificationJsonFromCode = AtlasType.toV1Json(request);
System.out.println(notificationJsonFromCode);
// Json without user and assert that the string can be deserialised
String notificationJson = "{\n" + " \"entities\": [\n" + " {\n" + " \"jsonClass\": \"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference\",\n" + " \"id\": {\n" + " \"jsonClass\": \"org.apache.atlas.typesystem.json.InstanceSerialization$_Id\",\n" + " \"id\": \"-1459493350903186000\",\n" + " \"version\": 0,\n" + " \"typeName\": \"sometype\",\n" + " \"state\": \"ACTIVE\"\n" + " },\n" + " \"typeName\": \"sometype\",\n" + " \"values\": {\n" + " \"attr\": \"value\"\n" + " },\n" + " \"traitNames\": [],\n" + " \"traits\": {}\n" + " }\n" + " ],\n" + " \"type\": \"ENTITY_CREATE\"\n" + "}";
HookNotification actualNotification = deserializer.deserialize(notificationJson);
assertEquals(actualNotification.getType(), HookNotificationType.ENTITY_CREATE);
assertEquals(actualNotification.getUser(), HookNotification.UNKNOW_USER);
}
Aggregations