REST API modifications to take application ID/Kep pair to fetch intents.
Change-Id: Icee85c6d801c92d94c6905f1d4316f63fea4e560
Reference: ONOS-1007
diff --git a/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
index d7c288e..7a2ce15 100644
--- a/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
@@ -32,6 +32,7 @@
import org.onosproject.codec.CodecService;
import org.onosproject.codec.impl.CodecManager;
import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.core.IdGenerator;
import org.onosproject.net.NetworkResource;
@@ -63,6 +64,7 @@
@Ignore
public class IntentsResourceTest extends ResourceTest {
final IntentService mockIntentService = createMock(IntentService.class);
+ final CoreService mockCoreService = createMock(CoreService.class);
final HashSet<Intent> intents = new HashSet<>();
private static final ApplicationId APP_ID = new DefaultApplicationId(1, "test");
private IdGenerator mockGenerator;
@@ -105,6 +107,7 @@
this.id = id;
}
+ @Override
public String toString() {
return "Resource " + Integer.toString(id);
}
@@ -260,14 +263,14 @@
@Before
public void setUpTest() {
expect(mockIntentService.getIntents()).andReturn(intents).anyTimes();
-
// Register the services needed for the test
final CodecManager codecService = new CodecManager();
codecService.activate();
ServiceDirectory testDirectory =
new TestServiceDirectory()
.add(IntentService.class, mockIntentService)
- .add(CodecService.class, codecService);
+ .add(CodecService.class, codecService)
+ .add(CoreService.class, mockCoreService);
BaseResource.setServiceDirectory(testDirectory);
@@ -344,10 +347,15 @@
expect(mockIntentService.getIntent(Key.of(0, APP_ID)))
.andReturn(intent)
.anyTimes();
+ expect(mockIntentService.getIntent(Key.of("0", APP_ID)))
+ .andReturn(intent)
+ .anyTimes();
replay(mockIntentService);
-
+ expect(mockCoreService.getAppId(APP_ID.id()))
+ .andReturn(APP_ID).anyTimes();
+ replay(mockCoreService);
final WebResource rs = resource();
- final String response = rs.path("intents/0").get(String.class);
+ final String response = rs.path("intents/1/0").get(String.class);
final JsonObject result = JsonObject.readFrom(response);
assertThat(result, matchesIntent(intent));
}