Search in sources :

Example 66 with Id

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());
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Struct(org.apache.atlas.v1.model.instance.Struct) Test(org.testng.annotations.Test)

Example 67 with Id

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);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) Test(org.testng.annotations.Test)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)62 Test (org.testng.annotations.Test)39 Id (org.apache.atlas.v1.model.instance.Id)38 Struct (org.apache.atlas.v1.model.instance.Struct)15 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)11 List (java.util.List)7 AtlasException (org.apache.atlas.AtlasException)6 AtlasServiceException (org.apache.atlas.AtlasServiceException)6 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)5 HashMap (java.util.HashMap)4 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)4 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)4 Feed (org.apache.falcon.entity.v0.feed.Feed)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 Consumes (javax.ws.rs.Consumes)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WebApplicationException (javax.ws.rs.WebApplicationException)3