|
|
|
@ -18,6 +18,8 @@ class IndexNotificationsJobTest {
|
|
|
|
|
|
|
|
|
|
private List<Subscription> subscriptions;
|
|
|
|
|
|
|
|
|
|
private static final int N_TIMES = 1_000_000;
|
|
|
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
|
void setUp() throws Exception {
|
|
|
|
|
final Subscription s = new Subscription();
|
|
|
|
@ -32,53 +34,87 @@ class IndexNotificationsJobTest {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PROJECT");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
assertEquals(0, res.getData().size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void testGenerateNotifications_topic_match() {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PID");
|
|
|
|
|
event.setMap(new MappedFields());
|
|
|
|
|
event.getMap().setTargetDatasourceName("reposiTUm");
|
|
|
|
|
event.getMap().setTrust(0.8f);
|
|
|
|
|
|
|
|
|
|
System.out.println("no topic - execution time (ms): " + (end - start));
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
assertEquals(1, res.getData().size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assertEquals(0, res.getData().size());
|
|
|
|
|
@Test
|
|
|
|
|
void testGenerateNotifications_topic_no_match() {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PID");
|
|
|
|
|
event.setMap(new MappedFields());
|
|
|
|
|
event.getMap().setTargetDatasourceName("Puma");
|
|
|
|
|
event.getMap().setTrust(0.8f);
|
|
|
|
|
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
assertEquals(0, res.getData().size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void testGenerateNotifications_invalid_topic_repeated() {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PROJECT");
|
|
|
|
|
|
|
|
|
|
// warm up
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
for (int i = 0; i < N_TIMES; i++) {
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
}
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
System.out.println(String.format("no topic - repeated %s times - execution time: %s ms ", N_TIMES, end - start));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void testGenerateNotifications_topic_match() {
|
|
|
|
|
void testGenerateNotifications_topic_match_repeated() {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PID");
|
|
|
|
|
event.setMap(new MappedFields());
|
|
|
|
|
event.getMap().setTargetDatasourceName("reposiTUm");
|
|
|
|
|
event.getMap().setTrust(0.8f);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
// warm up
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
|
|
|
|
|
System.out.println("topic match - execution time (ms): " + (end - start));
|
|
|
|
|
|
|
|
|
|
assertEquals(1, res.getData().size());
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
for (int i = 0; i < N_TIMES; i++) {
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
}
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
System.out.println(String.format("topic match - repeated %s times - execution time: %s ms ", N_TIMES, end - start));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void testGenerateNotifications_topic_no_match() {
|
|
|
|
|
void testGenerateNotifications_topic_no_match_repeated() {
|
|
|
|
|
final Event event = new Event();
|
|
|
|
|
event.setTopic("ENRICH/MISSING/PID");
|
|
|
|
|
event.setMap(new MappedFields());
|
|
|
|
|
event.getMap().setTargetDatasourceName("Puma");
|
|
|
|
|
event.getMap().setTrust(0.8f);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
final NotificationGroup res = IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
System.out.println("topic no match - execution time (ms): " + (end - start));
|
|
|
|
|
// warm up
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
|
|
|
|
|
assertEquals(0, res.getData().size());
|
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
|
for (int i = 0; i < N_TIMES; i++) {
|
|
|
|
|
IndexNotificationsJob.generateNotifications(event, subscriptions, 0);
|
|
|
|
|
}
|
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
|
System.out.println(String.format("topic no match - repeated %s times - execution time: %s ms ", N_TIMES, end - start));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|