Skip to content

Commit 39b8dc2

Browse files
Add support for fetching multiple failed notifications (#385)
* You can now fetch multiple notifications in the same way you do with subscriptions: /failed-notifications?subscriptionName=Sub1,Sub2 * Switched all references from missed- to failed-notifications * Removed failed notifications database that was separate from the main eiffel intelligence database
1 parent 5ff2ddf commit 39b8dc2

File tree

60 files changed

+339
-339
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+339
-339
lines changed

src/functionaltests/java/com/ericsson/ei/notifications/trigger/SubscriptionNotificationSteps.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
@Ignore
4848
@TestPropertySource(properties = { "spring.data.mongodb.database: SubscriptionNotificationSteps",
49-
"failed.notification.database-name: SubscriptionNotificationSteps-failedNotifications",
49+
"failed.notification.collection-name: SubscriptionNotificationSteps-failedNotifications",
5050
"rabbitmq.exchange.name: SubscriptionNotificationSteps-exchange",
5151
"rabbitmq.consumerName: SubscriptionNotificationSteps-consumer" })
5252
public class SubscriptionNotificationSteps extends FunctionalTestBase {
@@ -75,9 +75,6 @@ public class SubscriptionNotificationSteps extends FunctionalTestBase {
7575
@Value("${spring.data.mongodb.database}")
7676
private String database;
7777

78-
@Value("${failed.notification.database-name}")
79-
private String failedNotificationDatabase;
80-
8178
@Value("${failed.notification.collection-name}")
8279
private String failedNotificationCollection;
8380

@@ -98,7 +95,6 @@ public class SubscriptionNotificationSteps extends FunctionalTestBase {
9895
@Before()
9996
public void beforeScenario() {
10097
mongoDBHandler.dropDatabase(database);
101-
mongoDBHandler.dropDatabase(failedNotificationDatabase);
10298
}
10399

104100
@After()
@@ -204,17 +200,15 @@ public void check_rest_subscriptions_were_triggered() throws Throwable {
204200
mockClient.reset();
205201
}
206202

207-
@Then("Missed notification db should contain (\\d+) objects")
208-
public void missed_notification_db_should_contain_x_objects(int maxObjectsInDB) throws Throwable {
203+
@Then("Failed notification db should contain (\\d+) objects")
204+
public void failed_notification_db_should_contain_x_objects(int maxObjectsInDB) throws Throwable {
209205
int minWaitTime = 5;
210206
int maxWaittime = 20;
211207

212208
final MongoCondition condition = MongoCondition.emptyCondition();
213-
int missedNotifications = getDbSizeForCondition(minWaitTime, maxWaittime, maxObjectsInDB, condition);
209+
int failedNotifications = getDbSizeForCondition(minWaitTime, maxWaittime, maxObjectsInDB, condition);
214210

215-
assertEquals(missedNotifications, maxObjectsInDB);
216-
assertEquals("Number of missed notifications saved in the database: " + missedNotifications, maxObjectsInDB,
217-
missedNotifications);
211+
assertEquals(maxObjectsInDB, failedNotifications);
218212
}
219213

220214
@Then("^No subscription is retriggered$")
@@ -443,7 +437,7 @@ private int getDbSizeForCondition(int minWaitTime, int maxWaitTime, int expected
443437
List<String> queryResult = null;
444438

445439
while (System.currentTimeMillis() < maxTime) {
446-
queryResult = mongoDBHandler.find(failedNotificationDatabase,
440+
queryResult = mongoDBHandler.find(database,
447441
failedNotificationCollection, condition);
448442

449443
if (queryResult.size() == expectedSize) {

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
"aggregated.collection.ttlValue:1",
4848
"notification.failAttempt:1",
4949
"spring.data.mongodb.database: TestTTLSteps",
50-
"failed.notification.database-name: TestTTLSteps-failedNotifications",
50+
"failed.notification.collection-name: TestTTLSteps-failedNotifications",
5151
"rabbitmq.exchange.name: TestTTLSteps-exchange",
5252
"rabbitmq.consumerName: TestTTLStepsConsumer"})
5353
public class TestTTLSteps extends FunctionalTestBase {
5454
private static final Logger LOGGER = LoggerFactory.getLogger(TestTTLSteps.class);
5555
private static final String BASE_URL = "localhost";
56-
private static final String ENDPOINT = "/missed_notification";
56+
private static final String INVALID_ENDPOINT = "/invalid-endpoint";
5757
private static final String SUBSCRIPTION_NAME = "Subscription_1";
5858

5959
private static final String SUBSCRIPTION_NAME_3 = "Subscription_Test_3";
@@ -75,14 +75,11 @@ public class TestTTLSteps extends FunctionalTestBase {
7575
private MockServerClient mockServerClient;
7676
private ClientAndServer clientAndServer;
7777

78-
@Value("${failed.notification.database-name}")
79-
private String failedNotificationDatabase;
80-
8178
@Value("${failed.notification.collection-name}")
8279
private String failedNotificationCollection;
8380

8481
@Value("${spring.data.mongodb.database}")
85-
private String dataBase;
82+
private String database;
8683

8784
@Value("${aggregated.collection.name}")
8885
private String collection;
@@ -109,7 +106,7 @@ public void afterScenario() throws IOException {
109106
public void create_subscription_object() throws IOException, JSONException {
110107

111108
LOGGER.debug("Starting scenario @TestNotificationRetries.");
112-
mongoDBHandler.dropCollection(failedNotificationDatabase, failedNotificationCollection);
109+
mongoDBHandler.dropCollection(database, failedNotificationCollection);
113110

114111
String subscriptionStr = FileUtils.readFileToString(new File(SUBSCRIPTION_FILE_PATH), "utf-8");
115112

@@ -129,7 +126,7 @@ public void inform_subscriber() throws IOException, AuthenticationException {
129126
@Then("^Verify that request has been retried")
130127
public void verify_request_has_been_made() throws JSONException {
131128

132-
String retrievedRequests = mockServerClient.retrieveRecordedRequests(request().withPath(ENDPOINT), Format.JSON);
129+
String retrievedRequests = mockServerClient.retrieveRecordedRequests(request().withPath(INVALID_ENDPOINT), Format.JSON);
133130
JSONArray requests = new JSONArray(retrievedRequests);
134131

135132
// received requests include number of retries
@@ -139,11 +136,11 @@ public void verify_request_has_been_made() throws JSONException {
139136
@Then("^Check failed notification is in database$")
140137
public void check_failed_notification_is_in_database() {
141138
final MongoCondition condition = MongoCondition.subscriptionNameCondition(SUBSCRIPTION_NAME);
142-
List<String> result = mongoDBHandler.find(failedNotificationDatabase,
139+
List<String> result = mongoDBHandler.find(database,
143140
failedNotificationCollection, condition);
144141

145142
assertEquals(1, result.size());
146-
assertEquals("Could not find a missed notification matching the condition: " + condition,
143+
assertEquals("Could not find a failed notification matching the condition: " + condition,
147144
"\"" + SUBSCRIPTION_NAME + "\"", dbManager.getValueFromQuery(result, "subscriptionName", 0));
148145
}
149146

@@ -178,13 +175,13 @@ public void eiffel_events_are_sent() throws Throwable {
178175
public void aggregated_object_is_created() throws Throwable {
179176
// verify that aggregated object is created and present in db
180177
LOGGER.debug("Checking presence of aggregated Object");
181-
List<String> allObjects = mongoDBHandler.getAllDocuments(dataBase, collection);
178+
List<String> allObjects = mongoDBHandler.getAllDocuments(database, collection);
182179
assertEquals(1, allObjects.size());
183180
}
184181

185182
@When("^Failed notification is created$")
186183
public void a_failed_notification_is_created() throws Throwable {
187-
// verifying that missed notification is created and present in db
184+
// verifying that failed notification is created and present in db
188185
int expectedSize = 1;
189186
final MongoCondition condition = MongoCondition.subscriptionNameCondition(SUBSCRIPTION_NAME_3);
190187

@@ -209,7 +206,7 @@ public void the_Aggregated_Object_document_should_be_deleted_from_the_database()
209206
List<String> allObjects = null;
210207
// To be sure at least one minute has passed since creation of aggregated object
211208
TimeUnit.MINUTES.sleep(1);
212-
allObjects = mongoDBHandler.getAllDocuments(dataBase, collection);
209+
allObjects = mongoDBHandler.getAllDocuments(database, collection);
213210
assertEquals("Database is not empty.", true, allObjects.isEmpty());
214211
}
215212

@@ -224,7 +221,7 @@ private void setUpMockServer() {
224221
mockServerClient = new MockServerClient(BASE_URL, port);
225222

226223
// set up expectations on mock server to get calls on this endpoint
227-
mockServerClient.when(request().withMethod("POST").withPath(ENDPOINT))
224+
mockServerClient.when(request().withMethod("POST").withPath(INVALID_ENDPOINT))
228225
.respond(HttpResponse.response().withStatusCode(500));
229226
}
230227

@@ -242,7 +239,7 @@ private int getNotificationForExpectedSize(int expectedSize, MongoCondition cond
242239
List<String> notificationExist = null;
243240

244241
while (System.currentTimeMillis() < maxTime) {
245-
notificationExist = mongoDBHandler.find(failedNotificationDatabase,
242+
notificationExist = mongoDBHandler.find(database,
246243
failedNotificationCollection,
247244
condition);
248245

0 commit comments

Comments
 (0)