[ONOS-4409] Merge getApp REST methods into one, revise unit test
Change-Id: I47e5dd1d795404d3ba2c73487858a3d389790ac9
diff --git a/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java b/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
index e2a6bb1..f1796dc 100644
--- a/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
+++ b/web/api/src/test/java/org/onosproject/rest/resources/ApplicationsResourceTest.java
@@ -22,6 +22,7 @@
import com.google.common.collect.ImmutableSet;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onlab.osgi.ServiceDirectory;
@@ -42,6 +43,7 @@
import org.onosproject.core.DefaultApplicationId;
import org.onosproject.core.Version;
+import javax.ws.rs.NotFoundException;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
@@ -487,8 +489,8 @@
replay(coreService);
WebTarget wt = target();
- String response = wt.path("applications/ids/short")
- .queryParam("id", 1).request().get(String.class);
+ String response = wt.path("applications/ids/entry")
+ .queryParam("id", 1).request().get(String.class);
JsonObject result = Json.parse(response).asObject();
assertThat(result, notNullValue());
@@ -507,7 +509,7 @@
replay(coreService);
WebTarget wt = target();
- String response = wt.path("applications/ids/name")
+ String response = wt.path("applications/ids/entry")
.queryParam("name", "app2").request().get(String.class);
JsonObject result = Json.parse(response).asObject();
@@ -517,4 +519,19 @@
verify(coreService);
}
+
+ /**
+ * Tests a GET of an applicationId without specifying any parameters.
+ */
+ @Test
+ public void getAppWithNoParam() {
+ WebTarget wt = target();
+
+ try {
+ wt.path("applications/ids/entry").request().get();
+ } catch (NotFoundException ex) {
+ Assert.assertThat(ex.getMessage(),
+ containsString("HTTP 404 Not Found"));
+ }
+ }
}