Search in sources :

Example 71 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable 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);
    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)

Example 72 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable in project atlas by apache.

the class HookNotificationDeserializerTest method generateLargeEntityWithTrait.

private Referenceable generateLargeEntityWithTrait() {
    Referenceable ret = EntityNotificationTest.getEntity("id", new Struct("MyTrait", Collections.<String, Object>emptyMap()));
    // add 100 attributes, each with value of size 10k
    // Json Size=1,027,984; GZipped Size=16,387 ==> will compress, but not split
    // use the same value for all attributes - to aid better compression
    String attrValue = RandomStringUtils.randomAlphanumeric(10 * 1024);
    for (int i = 0; i < 100; i++) {
        ret.set("attr_" + i, attrValue);
    }
    return ret;
}
Also used : Referenceable(org.apache.atlas.v1.model.instance.Referenceable) Struct(org.apache.atlas.v1.model.instance.Struct)

Example 73 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable 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 74 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable 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);
    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 75 with Referenceable

use of org.apache.atlas.v1.model.instance.Referenceable 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);
    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)143 Test (org.testng.annotations.Test)64 Id (org.apache.atlas.v1.model.instance.Id)37 Struct (org.apache.atlas.v1.model.instance.Struct)23 ArrayList (java.util.ArrayList)20 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)15 HashMap (java.util.HashMap)12 List (java.util.List)10 AtlasException (org.apache.atlas.AtlasException)10 HookNotification (org.apache.atlas.model.notification.HookNotification)10 Map (java.util.Map)9 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)9 AtlasServiceException (org.apache.atlas.AtlasServiceException)8 EntityAuditEvent (org.apache.atlas.EntityAuditEvent)8 EntityNotificationV1 (org.apache.atlas.v1.model.notification.EntityNotificationV1)7 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)7 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityResult (org.apache.atlas.model.legacy.EntityResult)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)5