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 {
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getVirtualNetworkTenants() {
public Response getVirtualNetworkTenantIds() {
Iterable<TenantId> tenantIds = vnetAdminService.getTenantIds();
return ok(encodeArray(TenantId.class, "tenants", tenantIds)).build();
}
......@@ -109,24 +109,6 @@ public class TenantWebResource extends AbstractWebResource {
}
/**
* Removes the specified tenant with the specified tenant identifier.
*
* @param stream deviceIds JSON stream
* @return 200 OK, 404 not found
* @onos.rsModel TenantId
*/
@DELETE
public Response removeTenantId(InputStream stream) {
try {
final TenantId tid = getTenantIdFromJsonStream(stream);
vnetAdminService.unregisterTenantId(tid);
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
return Response.ok().build();
}
/**
* Get the tenant identifier from the JSON stream.
*
* @param stream TenantId JSON stream
......
......@@ -295,26 +295,6 @@ public class TenantWebResourceTest extends ResourceTest {
}
/**
* Tests removing a tenant id with DELETE request via JSON stream.
*/
@Test
public void testDeleteViaJson() {
mockVnetAdminService.unregisterTenantId(anyObject());
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target()
.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
InputStream jsonStream = TenantWebResourceTest.class
.getResourceAsStream("post-tenant.json");
Response response = wt.request().method("DELETE", Entity.json(jsonStream));
// assertThat(response.getStatus(), is(HttpURLConnection.HTTP_OK));
// verify(mockVnetAdminService);
}
/**
* Tests that a DELETE of a non-existent tenant id throws an exception.
*/
@Test
......
......@@ -226,12 +226,12 @@ public class VirtualNetworkWebResourceTest extends ResourceTest {
* @param obj virtual network object we are looking for
* @param jsonFieldNames JSON field names to check against
* @param getValue function to retrieve value from virtual network object
* @param <T>
* @return JsonObjectMatcher
* @param <T> the type of virtual network object
* @return matcher
*/
private static <T> JsonObjectMatcher matchesVnetEntity(T obj, List<String> jsonFieldNames,
BiFunction<T, String, String> getValue) {
return new JsonObjectMatcher(obj, jsonFieldNames, getValue);
return new JsonObjectMatcher<T>(obj, jsonFieldNames, getValue);
}
/**
......