Skip to content

Commit d744416

Browse files
Functional Test for ttl and time indexing added to docs before inserting into mongoDB (#172)
* FT-TTL for missednotification * adding time to doc indexing * minor spelling mistake corrected * reviwed changes: date creation is now a static method in class DateUtils, added to InformSubscription as well * minor error removal * removed a scenario as this commit covers it * reviewed changes * java doc for date method * review:comments removed
1 parent 55977d2 commit d744416

File tree

7 files changed

+655
-602
lines changed

7 files changed

+655
-602
lines changed

src/functionaltests/java/com/ericsson/ei/notifications/ttl/TestTTLSteps.java

Lines changed: 189 additions & 196 deletions
Large diffs are not rendered by default.

src/functionaltests/resources/features/ttl.feature

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
@TtlAndNotifications
44
Feature: TestTTL
55

6-
@TestTTL
7-
Scenario: Test time to live for missed notification and aggregated object
8-
Given Missed notification is created in database with index "expTime"
9-
And Aggregated object is created in database with index "expTime"
10-
Then "aggregated_object" document has been deleted from "eiffel_intelligence" database
11-
And "Notification" document has been deleted from "MissedNotification" database
12-
136
@TestNotificationRetries
147
Scenario: Test notification retries
158
Given Subscription is created
169
When I want to inform subscriber
1710
Then Verify that request has been retried
1811
And Check missed notification is in database
12+
13+
@TestTTLforAutomaticSubscriptionTrigger
14+
Scenario: Test time to live for missed notification and aggregated object with an automatic subscription trigger flow setup
15+
Given A subscription is created at the end point "/subscriptions" with non-existent notification meta
16+
And I send an Eiffel event and consequently aggregated object and thereafter missed notification is created
17+
Then the Notification document should be deleted from the database according to ttl value
18+
And the Aggregated Object document should be deleted from the database according to ttl value
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[
2+
{
3+
"subscriptionName": "Subscription_Test_3",
4+
"repeat": false,
5+
"created": 1523473956269,
6+
"notificationType": "REST_POST",
7+
"notificationMeta": "http://eiffel-jenkins3:8080/job/ei-artifact-triggered-job/build",
8+
"restPostBodyMediaType": "application/x-www-form-urlencoded",
9+
"notificationMessageKeyValues": [
10+
{
11+
"formkey": "json",
12+
"formvalue": "{parameter: [{ name: 'jsonparams', value : to_string(@) }]}"
13+
}
14+
],
15+
"requirements": [
16+
{
17+
"conditions": [
18+
{
19+
"jmespath": "gav.groupId=='com.mycompany.myproduct'"
20+
}
21+
]
22+
}
23+
]
24+
}
25+
]
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.ericsson.ei.handlers;
2+
3+
import java.text.DateFormat;
4+
import java.text.ParseException;
5+
import java.text.SimpleDateFormat;
6+
import java.util.Date;
7+
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
10+
11+
12+
public class DateUtils {
13+
/**
14+
* This method creates the date object with
15+
* the current date for appending in the document
16+
* object before inserting it into mongoDB.
17+
*/
18+
public static Date getDate() throws ParseException {
19+
Logger log = (Logger) LoggerFactory.getLogger(ObjectHandler.class);
20+
Date date = new Date();
21+
try {
22+
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
23+
String time = dateFormat.format(date);
24+
date = dateFormat.parse(time);
25+
} catch (Exception e) {
26+
log.error(e.getMessage(), e);
27+
}
28+
return date;
29+
}
30+
}

0 commit comments

Comments
 (0)