Claudine Chiu
Committed by Gerrit Code Review

ONOS-4077: REST API's for virtual networks and tenants

Change-Id: Ic229c9bc78e4bfce20842717ae46a0b8acff0b76
...@@ -61,7 +61,7 @@ public class TenantWebResource extends AbstractWebResource { ...@@ -61,7 +61,7 @@ public class TenantWebResource extends AbstractWebResource {
61 */ 61 */
62 @GET 62 @GET
63 @Produces(MediaType.APPLICATION_JSON) 63 @Produces(MediaType.APPLICATION_JSON)
64 - public Response getVirtualNetworkTenants() { 64 + public Response getVirtualNetworkTenantIds() {
65 Iterable<TenantId> tenantIds = vnetAdminService.getTenantIds(); 65 Iterable<TenantId> tenantIds = vnetAdminService.getTenantIds();
66 return ok(encodeArray(TenantId.class, "tenants", tenantIds)).build(); 66 return ok(encodeArray(TenantId.class, "tenants", tenantIds)).build();
67 } 67 }
...@@ -109,24 +109,6 @@ public class TenantWebResource extends AbstractWebResource { ...@@ -109,24 +109,6 @@ public class TenantWebResource extends AbstractWebResource {
109 } 109 }
110 110
111 /** 111 /**
112 - * Removes the specified tenant with the specified tenant identifier.
113 - *
114 - * @param stream deviceIds JSON stream
115 - * @return 200 OK, 404 not found
116 - * @onos.rsModel TenantId
117 - */
118 - @DELETE
119 - public Response removeTenantId(InputStream stream) {
120 - try {
121 - final TenantId tid = getTenantIdFromJsonStream(stream);
122 - vnetAdminService.unregisterTenantId(tid);
123 - } catch (IOException e) {
124 - throw new IllegalArgumentException(e);
125 - }
126 - return Response.ok().build();
127 - }
128 -
129 - /**
130 * Get the tenant identifier from the JSON stream. 112 * Get the tenant identifier from the JSON stream.
131 * 113 *
132 * @param stream TenantId JSON stream 114 * @param stream TenantId JSON stream
......
...@@ -295,26 +295,6 @@ public class TenantWebResourceTest extends ResourceTest { ...@@ -295,26 +295,6 @@ public class TenantWebResourceTest extends ResourceTest {
295 } 295 }
296 296
297 /** 297 /**
298 - * Tests removing a tenant id with DELETE request via JSON stream.
299 - */
300 - @Test
301 - public void testDeleteViaJson() {
302 - mockVnetAdminService.unregisterTenantId(anyObject());
303 - expectLastCall();
304 - replay(mockVnetAdminService);
305 -
306 - WebTarget wt = target()
307 - .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
308 - InputStream jsonStream = TenantWebResourceTest.class
309 - .getResourceAsStream("post-tenant.json");
310 - Response response = wt.request().method("DELETE", Entity.json(jsonStream));
311 -
312 -// assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
313 -
314 -// verify(mockVnetAdminService);
315 - }
316 -
317 - /**
318 * Tests that a DELETE of a non-existent tenant id throws an exception. 298 * Tests that a DELETE of a non-existent tenant id throws an exception.
319 */ 299 */
320 @Test 300 @Test
......
...@@ -226,12 +226,12 @@ public class VirtualNetworkWebResourceTest extends ResourceTest { ...@@ -226,12 +226,12 @@ public class VirtualNetworkWebResourceTest extends ResourceTest {
226 * @param obj virtual network object we are looking for 226 * @param obj virtual network object we are looking for
227 * @param jsonFieldNames JSON field names to check against 227 * @param jsonFieldNames JSON field names to check against
228 * @param getValue function to retrieve value from virtual network object 228 * @param getValue function to retrieve value from virtual network object
229 - * @param <T> 229 + * @param <T> the type of virtual network object
230 - * @return JsonObjectMatcher 230 + * @return matcher
231 */ 231 */
232 private static <T> JsonObjectMatcher matchesVnetEntity(T obj, List<String> jsonFieldNames, 232 private static <T> JsonObjectMatcher matchesVnetEntity(T obj, List<String> jsonFieldNames,
233 BiFunction<T, String, String> getValue) { 233 BiFunction<T, String, String> getValue) {
234 - return new JsonObjectMatcher(obj, jsonFieldNames, getValue); 234 + return new JsonObjectMatcher<T>(obj, jsonFieldNames, getValue);
235 } 235 }
236 236
237 /** 237 /**
......