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