Search in sources :

Example 1 with EntityUpdateRequest

use of org.hypertrace.entity.query.service.v1.EntityUpdateRequest in project atlas by apache.

the class KafkaConsumerTest method assertMessagesEqual.

private void assertMessagesEqual(EntityUpdateRequest message, HookNotification consumedMessage, Referenceable entity) {
    assertEquals(consumedMessage.getType(), message.getType());
    assertEquals(consumedMessage.getUser(), message.getUser());
    assertTrue(consumedMessage instanceof EntityUpdateRequest);
    EntityUpdateRequest deserializedEntityUpdateRequest = (EntityUpdateRequest) consumedMessage;
    Referenceable deserializedEntity = deserializedEntityUpdateRequest.getEntities().get(0);
    assertEquals(deserializedEntity.getId(), entity.getId());
    assertEquals(deserializedEntity.getTypeName(), entity.getTypeName());
    assertEquals(deserializedEntity.getTraits(), entity.getTraits());
    assertEquals(deserializedEntity.getTrait(TRAIT_NAME), entity.getTrait(TRAIT_NAME));
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)

Example 2 with EntityUpdateRequest

use of org.hypertrace.entity.query.service.v1.EntityUpdateRequest in project atlas by apache.

the class HookNotificationDeserializerTest method testDeserializeCompressedMessage.

@Test
public void testDeserializeCompressedMessage() throws Exception {
    Referenceable entity = generateLargeEntityWithTrait();
    EntityUpdateRequest message = new EntityUpdateRequest("user1", entity);
    List<String> jsonMsgList = new ArrayList<>();
    AbstractNotification.createNotificationMessages(message, jsonMsgList, source);
    assertTrue(jsonMsgList.size() == 1);
    String compressedMsg = jsonMsgList.get(0);
    String uncompressedMsg = AtlasType.toV1Json(message);
    assertTrue(compressedMsg.length() < uncompressedMsg.length(), "Compressed message (" + compressedMsg.length() + ") should be shorter than uncompressed message (" + uncompressedMsg.length() + ")");
    HookNotification deserializedMessage = deserialize(jsonMsgList);
    assertEqualMessage(deserializedMessage, message);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList) EntityUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest) Test(org.testng.annotations.Test) EntityNotificationTest(org.apache.atlas.notification.entity.EntityNotificationTest)

Example 3 with EntityUpdateRequest

use of org.hypertrace.entity.query.service.v1.EntityUpdateRequest in project atlas by apache.

the class HookNotificationDeserializerTest method testDeserializeLegacyMessage.

// validate deserialization of legacy message, which doesn't use MessageVersion
@Test
public void testDeserializeLegacyMessage() throws Exception {
    Referenceable entity = generateEntityWithTrait();
    EntityUpdateRequest message = new EntityUpdateRequest("user1", entity);
    String jsonMsg = AtlasType.toV1Json(message);
    HookNotification deserializedMessage = deserialize(Collections.singletonList(jsonMsg));
    assertEqualMessage(deserializedMessage, message);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) EntityUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest) Test(org.testng.annotations.Test) EntityNotificationTest(org.apache.atlas.notification.entity.EntityNotificationTest)

Example 4 with EntityUpdateRequest

use of org.hypertrace.entity.query.service.v1.EntityUpdateRequest in project atlas by apache.

the class HookNotificationDeserializerTest method testDeserialize.

@Test
public void testDeserialize() throws Exception {
    Referenceable entity = generateEntityWithTrait();
    EntityUpdateRequest message = new EntityUpdateRequest("user1", entity);
    List<String> jsonMsgList = new ArrayList<>();
    AbstractNotification.createNotificationMessages(message, jsonMsgList, source);
    HookNotification deserializedMessage = deserialize(jsonMsgList);
    assertEqualMessage(deserializedMessage, message);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList) EntityUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest) Test(org.testng.annotations.Test) EntityNotificationTest(org.apache.atlas.notification.entity.EntityNotificationTest)

Example 5 with EntityUpdateRequest

use of org.hypertrace.entity.query.service.v1.EntityUpdateRequest in project atlas by apache.

the class HookNotificationDeserializerTest method testDeserializeSplitMessage.

@Test
public void testDeserializeSplitMessage() throws Exception {
    Referenceable entity = generateVeryLargeEntityWithTrait();
    EntityUpdateRequest message = new EntityUpdateRequest("user1", entity);
    List<String> jsonMsgList = new ArrayList<>();
    AbstractNotification.createNotificationMessages(message, jsonMsgList, source);
    assertTrue(jsonMsgList.size() > 1);
    HookNotification deserializedMessage = deserialize(jsonMsgList);
    assertEqualMessage(deserializedMessage, message);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Referenceable(org.apache.atlas.v1.model.instance.Referenceable) ArrayList(java.util.ArrayList) EntityUpdateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest) Test(org.testng.annotations.Test) EntityNotificationTest(org.apache.atlas.notification.entity.EntityNotificationTest)

Aggregations

Referenceable (org.apache.atlas.v1.model.instance.Referenceable)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 Test (org.testng.annotations.Test)7 HookNotification (org.apache.atlas.model.notification.HookNotification)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)6 ArrayList (java.util.ArrayList)3 EntityUpdateRequest (org.hypertrace.entity.query.service.v1.EntityUpdateRequest)3 ResultSetChunk (org.hypertrace.entity.query.service.v1.ResultSetChunk)3 Map (java.util.Map)2 JSONDocument (org.hypertrace.core.documentstore.JSONDocument)2 SingleValueKey (org.hypertrace.core.documentstore.SingleValueKey)2 UpdateEntityResponse (org.hypertrace.gateway.service.v1.entity.UpdateEntityResponse)2 Test (org.junit.jupiter.api.Test)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ServiceException (com.google.protobuf.ServiceException)1 HashMap (java.util.HashMap)1 MessageVersion (org.apache.atlas.model.notification.MessageVersion)1 IncompatibleVersionException (org.apache.atlas.notification.IncompatibleVersionException)1 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)1 ConsumerRecords (org.apache.kafka.clients.consumer.ConsumerRecords)1