@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("{networkId}/hosts")
    public Response getVirtualHosts(@PathParam("networkId") long networkId) {
        NetworkId nid = NetworkId.networkId(networkId);
        Set<VirtualHost> vhosts = vnetService.getVirtualHosts(nid);
        return ok(encodeArray(VirtualHost.class, "hosts", vhosts)).build();
    }
@Test
    public void testGetVirtualHostsArray() {
        NetworkId networkId = networkId3;
        final Set<VirtualHost> vhostSet = ImmutableSet.of(vhost1, vhost2);
        expect(mockVnetService.getVirtualHosts(networkId)).andReturn(vhostSet).anyTimes();
        replay(mockVnetService);

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

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

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

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

        vhostSet.forEach(vhost -> assertThat(vnetJsonArray, hasVhost(vhost)));

        verify(mockVnetService);
    }