@GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getVirtualNetworks() {
        Set<TenantId> tenantIds = vnetAdminService.getTenantIds();
        List<VirtualNetwork> allVnets = tenantIds.stream()
                .map(tenantId -> vnetService.getVirtualNetworks(tenantId))
                .flatMap(Collection::stream)
                .collect(Collectors.toList());
        return ok(encodeArray(VirtualNetwork.class, "vnets", allVnets)).build();
    }
@Test
    public void testGetVirtualNetworksArray() {
        final Set<VirtualNetwork> vnetSet = ImmutableSet.of(vnet1, vnet2, vnet3, vnet4);
        expect(mockVnetAdminService.getTenantIds()).andReturn(ImmutableSet.of(tenantId3)).anyTimes();
        replay(mockVnetAdminService);
        expect(mockVnetService.getVirtualNetworks(tenantId3)).andReturn(vnetSet).anyTimes();
        replay(mockVnetService);

        WebTarget wt = target();
        String response = wt.path("vnets").request().get(String.class);
        assertThat(response, containsString("{\"vnets\":["));

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

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

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

        vnetSet.forEach(vnet -> assertThat(vnetJsonArray, hasVnet(vnet)));

        verify(mockVnetService);
        verify(mockVnetAdminService);
    }