use of org.apache.atlas.model.notification.MessageVersion in project atlas by apache.
the class AtlasNotificationMessageTest method testCompareVersion.
@Test
public void testCompareVersion() throws Exception {
MessageVersion version1 = new MessageVersion("1.0.0");
MessageVersion version2 = new MessageVersion("2.0.0");
MessageVersion version3 = new MessageVersion("0.5.0");
AtlasNotificationMessage<String> atlasNotificationMessage = new AtlasNotificationMessage<>(version1, "a");
assertTrue(atlasNotificationMessage.compareVersion(version1) == 0);
assertTrue(atlasNotificationMessage.compareVersion(version2) < 0);
assertTrue(atlasNotificationMessage.compareVersion(version3) > 0);
}
use of org.apache.atlas.model.notification.MessageVersion in project atlas by apache.
the class KafkaConsumerTest method testNextVersionMismatch.
@Test
public void testNextVersionMismatch() throws Exception {
Referenceable entity = getEntity(TRAIT_NAME);
EntityUpdateRequest message = new EntityUpdateRequest("user1", entity);
String json = AtlasType.toV1Json(new AtlasNotificationMessage<>(new MessageVersion("2.0.0"), message));
TopicPartition tp = new TopicPartition("ATLAS_HOOK", 0);
List<ConsumerRecord<String, String>> klist = Collections.singletonList(new ConsumerRecord<>("ATLAS_HOOK", 0, 0L, "mykey", json));
Map mp = Collections.singletonMap(tp, klist);
ConsumerRecords records = new ConsumerRecords(mp);
kafkaConsumer.assign(Collections.singletonList(tp));
when(kafkaConsumer.poll(100L)).thenReturn(records);
AtlasKafkaConsumer consumer = new AtlasKafkaConsumer(NotificationType.HOOK, kafkaConsumer, false, 100L);
try {
List<AtlasKafkaMessage<HookNotification>> messageList = consumer.receive();
assertTrue(messageList.size() > 0);
HookNotification consumedMessage = messageList.get(0).getMessage();
fail("Expected VersionMismatchException!");
} catch (IncompatibleVersionException e) {
e.printStackTrace();
}
}
use of org.apache.atlas.model.notification.MessageVersion in project atlas by apache.
the class MessageVersionTest method testHashCode.
@Test
public void testHashCode() throws Exception {
MessageVersion version1 = new MessageVersion("1.0.0");
MessageVersion version2 = new MessageVersion("1.0.0");
MessageVersion version3 = new MessageVersion("1");
assertEquals(version1.hashCode(), version2.hashCode());
assertEquals(version1.hashCode(), version3.hashCode());
}
use of org.apache.atlas.model.notification.MessageVersion in project atlas by apache.
the class MessageVersionTest method testEquals.
@Test
public void testEquals() throws Exception {
MessageVersion version1 = new MessageVersion("1.0.0");
MessageVersion version2 = new MessageVersion("1.0.0");
MessageVersion version3 = new MessageVersion("2.0.0");
MessageVersion version4 = new MessageVersion("1");
MessageVersion version5 = new MessageVersion("1.5");
MessageVersion version6 = new MessageVersion("1.0.5");
assertTrue(version1.equals(version2));
assertTrue(version2.equals(version1));
assertFalse(version1.equals(version3));
assertFalse(version3.equals(version1));
assertTrue(version1.equals(version4));
assertTrue(version4.equals(version1));
assertFalse(version1.equals(version5));
assertFalse(version5.equals(version1));
assertFalse(version1.equals(version6));
assertFalse(version6.equals(version1));
}
use of org.apache.atlas.model.notification.MessageVersion in project atlas by apache.
the class MessageVersionTest method testCompareTo.
@Test
public void testCompareTo() throws Exception {
MessageVersion version1 = new MessageVersion("1.0.0");
MessageVersion version2 = new MessageVersion("1.0.0");
MessageVersion version3 = new MessageVersion("2.0.0");
MessageVersion version4 = new MessageVersion("1");
MessageVersion version5 = new MessageVersion("1.5");
MessageVersion version6 = new MessageVersion("1.0.5");
assertTrue(version1.compareTo(version2) == 0);
assertTrue(version2.compareTo(version1) == 0);
assertTrue(version1.compareTo(version3) < 0);
assertTrue(version3.compareTo(version1) > 0);
assertTrue(version1.compareTo(version4) == 0);
assertTrue(version4.compareTo(version1) == 0);
assertTrue(version1.compareTo(version5) < 0);
assertTrue(version5.compareTo(version1) > 0);
assertTrue(version1.compareTo(version6) < 0);
assertTrue(version6.compareTo(version1) > 0);
}
Aggregations