6
6
import com .ericsson .ei .services .ISubscriptionService ;
7
7
import com .ericsson .ei .subscriptionhandler .RunSubscription ;
8
8
import com .ericsson .ei .utils .FunctionalTestBase ;
9
+ import com .ericsson .ei .utils .HttpRequest ;
9
10
import com .fasterxml .jackson .databind .JsonNode ;
10
11
import com .fasterxml .jackson .databind .ObjectMapper ;
11
12
import com .fasterxml .jackson .databind .node .ArrayNode ;
12
-
13
13
import cucumber .api .java .Before ;
14
14
import cucumber .api .java .en .Given ;
15
15
import cucumber .api .java .en .Then ;
22
22
import org .junit .Ignore ;
23
23
import org .springframework .beans .factory .annotation .Autowired ;
24
24
import org .springframework .beans .factory .annotation .Value ;
25
- import org .springframework .boot .test . autoconfigure . web .servlet . AutoConfigureMockMvc ;
25
+ import org .springframework .boot .web .server . LocalServerPort ;
26
26
import org .springframework .http .HttpStatus ;
27
- import org .springframework .http .MediaType ;
28
- import org .springframework .test .web .servlet .MockMvc ;
29
- import org .springframework .test .web .servlet .MvcResult ;
30
- import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
27
+ import org .springframework .http .ResponseEntity ;
31
28
32
29
import java .io .File ;
33
30
import java .io .IOException ;
39
36
import static org .junit .Assert .assertTrue ;
40
37
41
38
@ Ignore
42
- @ AutoConfigureMockMvc
43
39
public class SubscriptionRepeatHandlerSteps extends FunctionalTestBase {
40
+
44
41
private static final String AGGREGATED_OBJECT_FILE_PATH = "src/functionaltests/resources/aggragatedObject.json" ;
45
42
private static final String EVENTS_FILE_PATH = "src/test/resources/TestExecutionTestEvents.json" ;
46
43
private static final String RULES_FILE_PATH = "src/test/resources/TestExecutionObjectRules.json" ;
@@ -65,8 +62,8 @@ public class SubscriptionRepeatHandlerSteps extends FunctionalTestBase {
65
62
@ Value ("${subscription.collection.repeatFlagHandlerName}" )
66
63
private String repeatFlagHandlerCollection ;
67
64
68
- @ Autowired
69
- private MockMvc mockMvc ;
65
+ @ LocalServerPort
66
+ private int applicationPort ;
70
67
71
68
@ Autowired
72
69
private MongoDBHandler mongoDBHandler ;
@@ -116,12 +113,15 @@ public void in_MongoDb_RepeatFlagHandler_and_subscription_collections_the_subscr
116
113
}
117
114
118
115
@ Then ("^I make a DELETE request with subscription name \" ([^\" ]*)\" to the subscription REST API \" ([^\" ]*)\" $" )
119
- public void i_make_a_DELETE_request_with_subscription_name_to_the_subscription_REST_API (String name ,
120
- String subscriptionEndPoint ) throws Exception {
121
- MvcResult result = mockMvc
122
- .perform (MockMvcRequestBuilders .delete (subscriptionEndPoint + name ).accept (MediaType .APPLICATION_JSON ))
123
- .andReturn ();
124
- assertEquals (HttpStatus .OK .value (), result .getResponse ().getStatus ());
116
+ public void i_make_a_DELETE_request_with_subscription_name_to_the_subscription_REST_API (String name , String subscriptionEndPoint ) throws Exception {
117
+ HttpRequest deleteRequest = new HttpRequest (HttpRequest .HttpMethod .DELETE );
118
+ ResponseEntity response = deleteRequest .setHost (getHostName ())
119
+ .setPort (applicationPort )
120
+ .setHeaders ("content-type" , "application/json" )
121
+ .setHeaders ("Accept" , "application/json" )
122
+ .setEndpoint (subscriptionEndPoint + name )
123
+ .performRequest ();
124
+ assertEquals (HttpStatus .OK .value (), response .getStatusCodeValue ());
125
125
}
126
126
127
127
@ Then ("^Check in MongoDB RepeatFlagHandler collection that the subscription has been removed$" )
@@ -154,9 +154,8 @@ public List<String> getEventNamesToSend() {
154
154
155
155
/**
156
156
* Process list of documents which gotten from RepeatFlagHandler collection
157
- *
158
- * @param resultRepeatFlagHandler
159
- * list from RepeatFlagHandler collection
157
+ *
158
+ * @param resultRepeatFlagHandler list from RepeatFlagHandler collection
160
159
* @param index
161
160
* @return value of aggregatedObjectId
162
161
*/
@@ -169,7 +168,7 @@ private String getAggregatedObjectId(List<String> resultRepeatFlagHandler, int i
169
168
170
169
/**
171
170
* Adding subscription to RepeatFlagHandler collection
172
- *
171
+ *
173
172
* @param subscriptionStrValue
174
173
* @param subscriptionObject
175
174
* @throws IOException
0 commit comments