Search in sources :

Example 1 with EntityNotification

use of org.apache.atlas.model.notification.EntityNotification in project atlas by apache.

the class EntityNotificationDeserializerTest method testDeserialize.

@Test
public void testDeserialize() throws Exception {
    Referenceable entity = EntityNotificationTest.getEntity("id");
    String traitName = "MyTrait";
    List<Struct> traits = Collections.singletonList(new Struct(traitName, Collections.<String, Object>emptyMap()));
    EntityNotificationV1 notification = new EntityNotificationV1(entity, EntityNotificationV1.OperationType.TRAIT_ADD, traits);
    List<String> jsonMsgList = new ArrayList<>();
    AbstractNotification.createNotificationMessages(notification, jsonMsgList);
    EntityNotification deserializedNotification = null;
    for (String jsonMsg : jsonMsgList) {
        deserializedNotification = deserializer.deserialize(jsonMsg);
        if (deserializedNotification != null) {
            break;
        }
    }
    assertTrue(deserializedNotification instanceof EntityNotificationV1);
    EntityNotificationV1 entityNotificationV1 = (EntityNotificationV1) deserializedNotification;
    assertEquals(entityNotificationV1.getOperationType(), notification.getOperationType());
    assertEquals(entityNotificationV1.getEntity().getId(), notification.getEntity().getId());
    assertEquals(entityNotificationV1.getEntity().getTypeName(), notification.getEntity().getTypeName());
    assertEquals(entityNotificationV1.getEntity().getTraits(), notification.getEntity().getTraits());
    assertEquals(entityNotificationV1.getEntity().getTrait(traitName), notification.getEntity().getTrait(traitName));
}
Also used : EntityNotificationV1(org.apache.atlas.v1.model.notification.EntityNotificationV1) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityNotification(org.apache.atlas.model.notification.EntityNotification) ArrayList(java.util.ArrayList) Struct(org.apache.atlas.v1.model.instance.Struct) Test(org.testng.annotations.Test)

Aggregations

ArrayList (java.util.ArrayList)1 EntityNotification (org.apache.atlas.model.notification.EntityNotification)1 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)1 Struct (org.apache.atlas.v1.model.instance.Struct)1 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)1 Test (org.testng.annotations.Test)1