@Test public void testDeleteVirtualLink() { NetworkId networkId = networkId3; mockVnetAdminService.removeVirtualLink(networkId, cp22, cp11); expectLastCall(); replay(mockVnetAdminService); WebTarget wt = target() .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); InputStream jsonStream = VirtualNetworkWebResourceTest.class .getResourceAsStream("post-virtual-link.json"); String reqLocation = "vnets/" + networkId.toString() + "/links"; Response response = wt.path(reqLocation).request().method("DELETE", Entity.json(jsonStream)); assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT)); verify(mockVnetAdminService); }
@DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) public Response removeVirtualLink(@PathParam("networkId") long networkId, InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode specifiedNetworkId = jsonTree.get("networkId"); if (specifiedNetworkId != null && specifiedNetworkId.asLong() != (networkId)) { throw new IllegalArgumentException(INVALID_FIELD + "networkId"); } final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this); vnetAdminService.removeVirtualLink(vlinkReq.networkId(), vlinkReq.src(), vlinkReq.dst()); } catch (IOException e) { throw new IllegalArgumentException(e); } return Response.noContent().build(); }
VirtualNetworkWebResource extends AbstractWebResource { @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) public Response removeVirtualLink(@PathParam("networkId") long networkId, InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode specifiedNetworkId = jsonTree.get("networkId"); if (specifiedNetworkId != null && specifiedNetworkId.asLong() != (networkId)) { throw new IllegalArgumentException(INVALID_FIELD + "networkId"); } final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this); vnetAdminService.removeVirtualLink(vlinkReq.networkId(), vlinkReq.src(), vlinkReq.dst()); } catch (IOException e) { throw new IllegalArgumentException(e); } return Response.noContent().build(); } }
VirtualNetworkWebResource extends AbstractWebResource { @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) public Response removeVirtualLink(@PathParam("networkId") long networkId, InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode specifiedNetworkId = jsonTree.get("networkId"); if (specifiedNetworkId != null && specifiedNetworkId.asLong() != (networkId)) { throw new IllegalArgumentException(INVALID_FIELD + "networkId"); } final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this); vnetAdminService.removeVirtualLink(vlinkReq.networkId(), vlinkReq.src(), vlinkReq.dst()); } catch (IOException e) { throw new IllegalArgumentException(e); } return Response.noContent().build(); }  }
VirtualNetworkWebResource extends AbstractWebResource { @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) public Response removeVirtualLink(@PathParam("networkId") long networkId, InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode specifiedNetworkId = jsonTree.get("networkId"); if (specifiedNetworkId != null && specifiedNetworkId.asLong() != (networkId)) { throw new IllegalArgumentException(INVALID_FIELD + "networkId"); } final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this); vnetAdminService.removeVirtualLink(vlinkReq.networkId(), vlinkReq.src(), vlinkReq.dst()); } catch (IOException e) { throw new IllegalArgumentException(e); } return Response.noContent().build(); }  @GET @Produces(MediaType.APPLICATION_JSON) Response getVirtualNetworks(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{tenantId}") Response getVirtualNetworkById(@PathParam("tenantId") String tenantId); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualNetwork(InputStream stream); @DELETE @Path("{networkId}") Response removeVirtualNetwork(@PathParam("networkId") long networkId); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices") Response getVirtualDevices(@PathParam("networkId") long networkId); @POST @Path("{networkId}/devices") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualDevice(@PathParam("networkId") long networkId,
                                        InputStream stream); @DELETE @Path("{networkId}/devices/{deviceId}") Response removeVirtualDevice(@PathParam("networkId") long networkId,
                                        @PathParam("deviceId") String deviceId); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices/{deviceId}/ports") Response getVirtualPorts(@PathParam("networkId") long networkId,
                                    @PathParam("deviceId") String deviceId); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices/{deviceId}/ports") Response createVirtualPort(@PathParam("networkId") long networkId,
                                      @PathParam("deviceId") String virtDeviceId,
                                      InputStream stream); @DELETE @Path("{networkId}/devices/{deviceId}/ports/{portNum}") Response removeVirtualPort(@PathParam("networkId") long networkId,
                                      @PathParam("deviceId") String deviceId,
                                      @PathParam("portNum") long portNum); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/links") Response getVirtualLinks(@PathParam("networkId") long networkId); @POST @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualLink(@PathParam("networkId") long networkId,
                                      InputStream stream); @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) Response removeVirtualLink(@PathParam("networkId") long networkId,
                                      InputStream stream); }
VirtualNetworkWebResource extends AbstractWebResource { @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) public Response removeVirtualLink(@PathParam("networkId") long networkId, InputStream stream) { try { ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); JsonNode specifiedNetworkId = jsonTree.get("networkId"); if (specifiedNetworkId != null && specifiedNetworkId.asLong() != (networkId)) { throw new IllegalArgumentException(INVALID_FIELD + "networkId"); } final VirtualLink vlinkReq = codec(VirtualLink.class).decode(jsonTree, this); vnetAdminService.removeVirtualLink(vlinkReq.networkId(), vlinkReq.src(), vlinkReq.dst()); } catch (IOException e) { throw new IllegalArgumentException(e); } return Response.noContent().build(); }  @GET @Produces(MediaType.APPLICATION_JSON) Response getVirtualNetworks(); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{tenantId}") Response getVirtualNetworkById(@PathParam("tenantId") String tenantId); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualNetwork(InputStream stream); @DELETE @Path("{networkId}") Response removeVirtualNetwork(@PathParam("networkId") long networkId); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices") Response getVirtualDevices(@PathParam("networkId") long networkId); @POST @Path("{networkId}/devices") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualDevice(@PathParam("networkId") long networkId,
                                        InputStream stream); @DELETE @Path("{networkId}/devices/{deviceId}") Response removeVirtualDevice(@PathParam("networkId") long networkId,
                                        @PathParam("deviceId") String deviceId); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices/{deviceId}/ports") Response getVirtualPorts(@PathParam("networkId") long networkId,
                                    @PathParam("deviceId") String deviceId); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/devices/{deviceId}/ports") Response createVirtualPort(@PathParam("networkId") long networkId,
                                      @PathParam("deviceId") String virtDeviceId,
                                      InputStream stream); @DELETE @Path("{networkId}/devices/{deviceId}/ports/{portNum}") Response removeVirtualPort(@PathParam("networkId") long networkId,
                                      @PathParam("deviceId") String deviceId,
                                      @PathParam("portNum") long portNum); @GET @Produces(MediaType.APPLICATION_JSON) @Path("{networkId}/links") Response getVirtualLinks(@PathParam("networkId") long networkId); @POST @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Response createVirtualLink(@PathParam("networkId") long networkId,
                                      InputStream stream); @DELETE @Path("{networkId}/links") @Consumes(MediaType.APPLICATION_JSON) Response removeVirtualLink(@PathParam("networkId") long networkId,
                                      InputStream stream);  }