@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("{networkId}/devices/{deviceId}/ports")
    public Response getVirtualPorts(@PathParam("networkId") long networkId,
                                    @PathParam("deviceId") String deviceId) {
        NetworkId nid = NetworkId.networkId(networkId);
        Iterable<VirtualPort> vports = vnetService.getVirtualPorts(nid, DeviceId.deviceId(deviceId));
        return ok(encodeArray(VirtualPort.class, "ports", vports)).build();
    }
@Test
    public void testGetVirtualPortsArray() {
        NetworkId networkId = networkId3;
        DeviceId deviceId = dev22.id();
        vportSet.add(vport23);
        vportSet.add(vport22);
        expect(mockVnetService.getVirtualPorts(networkId, deviceId)).andReturn(vportSet).anyTimes();
        replay(mockVnetService);

        WebTarget wt = target();
        String location = "vnets/" + networkId.toString()
                + "/devices/" + deviceId.toString() + "/ports";
        String response = wt.path(location).request().get(String.class);
        assertThat(response, containsString("{\"ports\":["));

        final JsonObject result = Json.parse(response).asObject();
        assertThat(result, notNullValue());

        assertThat(result.names(), hasSize(1));
        assertThat(result.names().get(0), is("ports"));

        final JsonArray vnetJsonArray = result.get("ports").asArray();
        assertThat(vnetJsonArray, notNullValue());
        assertEquals("Virtual ports array is not the correct size.",
                     vportSet.size(), vnetJsonArray.size());

        vportSet.forEach(vport -> assertThat(vnetJsonArray, hasVport(vport)));

        verify(mockVnetService);
    }