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));
}
Aggregations