47
47
"aggregated.collection.ttlValue:1" ,
48
48
"notification.failAttempt:1" ,
49
49
"spring.data.mongodb.database: TestTTLSteps" ,
50
- "failed.notification.database -name: TestTTLSteps-failedNotifications" ,
50
+ "failed.notification.collection -name: TestTTLSteps-failedNotifications" ,
51
51
"rabbitmq.exchange.name: TestTTLSteps-exchange" ,
52
52
"rabbitmq.consumerName: TestTTLStepsConsumer" })
53
53
public class TestTTLSteps extends FunctionalTestBase {
54
54
private static final Logger LOGGER = LoggerFactory .getLogger (TestTTLSteps .class );
55
55
private static final String BASE_URL = "localhost" ;
56
- private static final String ENDPOINT = "/missed_notification " ;
56
+ private static final String INVALID_ENDPOINT = "/invalid-endpoint " ;
57
57
private static final String SUBSCRIPTION_NAME = "Subscription_1" ;
58
58
59
59
private static final String SUBSCRIPTION_NAME_3 = "Subscription_Test_3" ;
@@ -75,14 +75,11 @@ public class TestTTLSteps extends FunctionalTestBase {
75
75
private MockServerClient mockServerClient ;
76
76
private ClientAndServer clientAndServer ;
77
77
78
- @ Value ("${failed.notification.database-name}" )
79
- private String failedNotificationDatabase ;
80
-
81
78
@ Value ("${failed.notification.collection-name}" )
82
79
private String failedNotificationCollection ;
83
80
84
81
@ Value ("${spring.data.mongodb.database}" )
85
- private String dataBase ;
82
+ private String database ;
86
83
87
84
@ Value ("${aggregated.collection.name}" )
88
85
private String collection ;
@@ -109,7 +106,7 @@ public void afterScenario() throws IOException {
109
106
public void create_subscription_object () throws IOException , JSONException {
110
107
111
108
LOGGER .debug ("Starting scenario @TestNotificationRetries." );
112
- mongoDBHandler .dropCollection (failedNotificationDatabase , failedNotificationCollection );
109
+ mongoDBHandler .dropCollection (database , failedNotificationCollection );
113
110
114
111
String subscriptionStr = FileUtils .readFileToString (new File (SUBSCRIPTION_FILE_PATH ), "utf-8" );
115
112
@@ -129,7 +126,7 @@ public void inform_subscriber() throws IOException, AuthenticationException {
129
126
@ Then ("^Verify that request has been retried" )
130
127
public void verify_request_has_been_made () throws JSONException {
131
128
132
- String retrievedRequests = mockServerClient .retrieveRecordedRequests (request ().withPath (ENDPOINT ), Format .JSON );
129
+ String retrievedRequests = mockServerClient .retrieveRecordedRequests (request ().withPath (INVALID_ENDPOINT ), Format .JSON );
133
130
JSONArray requests = new JSONArray (retrievedRequests );
134
131
135
132
// received requests include number of retries
@@ -139,11 +136,11 @@ public void verify_request_has_been_made() throws JSONException {
139
136
@ Then ("^Check failed notification is in database$" )
140
137
public void check_failed_notification_is_in_database () {
141
138
final MongoCondition condition = MongoCondition .subscriptionNameCondition (SUBSCRIPTION_NAME );
142
- List <String > result = mongoDBHandler .find (failedNotificationDatabase ,
139
+ List <String > result = mongoDBHandler .find (database ,
143
140
failedNotificationCollection , condition );
144
141
145
142
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 ,
147
144
"\" " + SUBSCRIPTION_NAME + "\" " , dbManager .getValueFromQuery (result , "subscriptionName" , 0 ));
148
145
}
149
146
@@ -178,13 +175,13 @@ public void eiffel_events_are_sent() throws Throwable {
178
175
public void aggregated_object_is_created () throws Throwable {
179
176
// verify that aggregated object is created and present in db
180
177
LOGGER .debug ("Checking presence of aggregated Object" );
181
- List <String > allObjects = mongoDBHandler .getAllDocuments (dataBase , collection );
178
+ List <String > allObjects = mongoDBHandler .getAllDocuments (database , collection );
182
179
assertEquals (1 , allObjects .size ());
183
180
}
184
181
185
182
@ When ("^Failed notification is created$" )
186
183
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
188
185
int expectedSize = 1 ;
189
186
final MongoCondition condition = MongoCondition .subscriptionNameCondition (SUBSCRIPTION_NAME_3 );
190
187
@@ -209,7 +206,7 @@ public void the_Aggregated_Object_document_should_be_deleted_from_the_database()
209
206
List <String > allObjects = null ;
210
207
// To be sure at least one minute has passed since creation of aggregated object
211
208
TimeUnit .MINUTES .sleep (1 );
212
- allObjects = mongoDBHandler .getAllDocuments (dataBase , collection );
209
+ allObjects = mongoDBHandler .getAllDocuments (database , collection );
213
210
assertEquals ("Database is not empty." , true , allObjects .isEmpty ());
214
211
}
215
212
@@ -224,7 +221,7 @@ private void setUpMockServer() {
224
221
mockServerClient = new MockServerClient (BASE_URL , port );
225
222
226
223
// 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 ))
228
225
.respond (HttpResponse .response ().withStatusCode (500 ));
229
226
}
230
227
@@ -242,7 +239,7 @@ private int getNotificationForExpectedSize(int expectedSize, MongoCondition cond
242
239
List <String > notificationExist = null ;
243
240
244
241
while (System .currentTimeMillis () < maxTime ) {
245
- notificationExist = mongoDBHandler .find (failedNotificationDatabase ,
242
+ notificationExist = mongoDBHandler .find (database ,
246
243
failedNotificationCollection ,
247
244
condition );
248
245
0 commit comments