Fix for ONOS-5417:Issue with Creating Flows using POST flows REST API
Change-Id: Ie608f2ef0447fc8c2a73f46df0e5b195c333fcbf
(cherry picked from commit 3565ca6f5b2b46ee2fe9b93aa7d0ea4df592830b)
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
index 2ecd373..74defed 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/FlowsResourceTest.java
@@ -33,7 +33,6 @@
import org.onosproject.app.ApplicationService;
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
-import org.onosproject.codec.impl.FlowRuleCodec;
import org.onosproject.core.CoreService;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.core.GroupId;
@@ -46,7 +45,6 @@
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.FlowEntry;
import org.onosproject.net.flow.FlowId;
-import org.onosproject.net.flow.FlowRule.FlowRemoveReason;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.flow.FlowRuleExtPayLoad;
import org.onosproject.net.flow.FlowRuleService;
@@ -404,7 +402,7 @@
.andReturn(NetTestTools.APP_ID).anyTimes();
expect(mockCoreService.getAppId(anyString()))
.andReturn(NetTestTools.APP_ID).anyTimes();
- expect(mockCoreService.registerApplication(FlowRuleCodec.REST_APP_ID))
+ expect(mockCoreService.registerApplication(anyString()))
.andReturn(APP_ID).anyTimes();
replay(mockCoreService);
@@ -880,8 +878,6 @@
*/
@Test
public void testPostWithoutAppId() {
- mockFlowService.applyFlowRules(anyObject());
- expectLastCall();
replay(mockFlowService);
WebTarget wt = target();
@@ -891,9 +887,7 @@
Response response = wt.path("flows/of:0000000000000001")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(jsonStream));
- assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));
- String location = response.getLocation().getPath();
- assertThat(location, Matchers.startsWith("/flows/of:0000000000000001/"));
+ assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NOT_FOUND));
}
/**
@@ -905,6 +899,9 @@
expectLastCall();
replay(mockFlowService);
+ expect(mockApplicationService.getId(anyObject())).andReturn(APP_ID).anyTimes();
+ replay(mockApplicationService);
+
WebTarget wt = target();
InputStream jsonStream = FlowsResourceTest.class
.getResourceAsStream("post-flow.json");