forked from D-Net/dnet-hadoop
test
This commit is contained in:
parent
31a6ad1d79
commit
0a9ef34b56
|
@ -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,16 +34,9 @@ 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();
|
||||
|
||||
System.out.println("no topic - execution time (ms): " + (end - start));
|
||||
|
||||
assertEquals(0, res.getData().size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateNotifications_topic_match() {
|
||||
|
@ -51,16 +46,9 @@ class IndexNotificationsJobTest {
|
|||
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();
|
||||
|
||||
System.out.println("topic match - execution time (ms): " + (end - start));
|
||||
|
||||
assertEquals(1, res.getData().size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenerateNotifications_topic_no_match() {
|
||||
|
@ -70,15 +58,63 @@ class IndexNotificationsJobTest {
|
|||
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));
|
||||
|
||||
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_repeated() {
|
||||
final Event event = new Event();
|
||||
event.setTopic("ENRICH/MISSING/PID");
|
||||
event.setMap(new MappedFields());
|
||||
event.getMap().setTargetDatasourceName("reposiTUm");
|
||||
event.getMap().setTrust(0.8f);
|
||||
|
||||
// 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("topic match - repeated %s times - execution time: %s ms ", N_TIMES, end - start));
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
// 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("topic no match - repeated %s times - execution time: %s ms ", N_TIMES, end - start));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue