Search in sources :

Example 11 with EntityCreateRequest

use of org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest in project atlas by apache.

the class AtlasHookTest method testAllFailedMessagesAreLogged.

@Test
public void testAllFailedMessagesAreLogged() throws NotificationException {
    List<HookNotification> hookNotifications = new ArrayList<HookNotification>() {

        {
            add(new EntityCreateRequest("user"));
        }
    };
    doThrow(new NotificationException(new Exception(), Arrays.asList("test message1", "test message2"))).when(notificationInterface).send(NotificationInterface.NotificationType.HOOK, hookNotifications);
    AtlasHook.notifyEntitiesInternal(hookNotifications, 2, notificationInterface, true, failedMessagesLogger);
    verify(failedMessagesLogger, times(1)).log("test message1");
    verify(failedMessagesLogger, times(1)).log("test message2");
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) ArrayList(java.util.ArrayList) NotificationException(org.apache.atlas.notification.NotificationException) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) NotificationException(org.apache.atlas.notification.NotificationException) Test(org.testng.annotations.Test)

Example 12 with EntityCreateRequest

use of org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest in project atlas by apache.

the class AtlasHookTest method testNotifyEntitiesRetriesOnException.

@Test
public void testNotifyEntitiesRetriesOnException() throws NotificationException {
    List<HookNotification> hookNotifications = new ArrayList<HookNotification>() {

        {
            add(new EntityCreateRequest("user"));
        }
    };
    doThrow(new NotificationException(new Exception())).when(notificationInterface).send(NotificationInterface.NotificationType.HOOK, hookNotifications);
    AtlasHook.notifyEntitiesInternal(hookNotifications, 2, notificationInterface, false, failedMessagesLogger);
    verify(notificationInterface, times(2)).send(NotificationInterface.NotificationType.HOOK, hookNotifications);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) ArrayList(java.util.ArrayList) NotificationException(org.apache.atlas.notification.NotificationException) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) NotificationException(org.apache.atlas.notification.NotificationException) Test(org.testng.annotations.Test)

Aggregations

EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)12 Test (org.testng.annotations.Test)10 HookNotification (org.apache.atlas.model.notification.HookNotification)8 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)6 ArrayList (java.util.ArrayList)5 NotificationException (org.apache.atlas.notification.NotificationException)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 AtlasKafkaMessage (org.apache.atlas.kafka.AtlasKafkaMessage)2 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)1 EntityStream (org.apache.atlas.repository.store.graph.v1.EntityStream)1 EntityPartialUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityPartialUpdateRequest)1 TopicPartition (org.apache.kafka.common.TopicPartition)1