ProjectsRepositoryImpl implements ProjectsRepository { @Override public List<FindNetworksResult> findNetworks(FindNetworksRequest findNetworksRequest) { QueryResult networksResult = queryRepository.query(findNetworksRequest.getPayload()); Data data = networksResult.getData(); Map<String, FindNetworksResult> resultsMap = new LinkedHashMap<>(); data.getRows().forEach(r -> { ValueFormatter vf = new ValueFormatter(data, r); String networkId = vf.getString("networks.id"); FindNetworksResult findNetworksResult = resultsMap.getOrDefault(networkId, new FindNetworksResult( vf.getString("networks.id"), vf.getString("networks.name"), vf.getString("projects.name"), vf.getString("networks.state"), Boolean.valueOf(vf.getString("networks.is_shared"))) ); String cidr = vf.getString("network_subnets.cidr"); findNetworksResult.getSubnets().add(cidr); resultsMap.put(networkId, findNetworksResult); }); return new ArrayList<>(resultsMap.values()); } @Autowired  ProjectsRepositoryImpl(QueryRepository queryRepository); @Override List<FindProjectsResult> findProjects(FindProjectsRequest findProjectsRequest); @Override List<FindFlavorsResult> findFlavors(FindFlavorsRequest findFlavorsRequest); @Override List<FindNetworksResult> findNetworks(FindNetworksRequest findNetworksRequest); @Override List<FindKeypairsResult> findKeypairs(FindKeypairsRequest findKeypairsRequest);  }
@Test public void testFindNetworks() { Project project = EntityGenerator.getProject(); Network network = EntityGenerator.getNetwork(); QueryResult queryResult = createMockNetworksResult(project, network); mockQueryRepository.addQueryResult(queryResult); FindNetworksRequest findNetworksRequest = requestProvider.get(FindNetworksRequest.class); List<FindNetworksResult> networks = projectsRepository.findNetworks(findNetworksRequest); assertThat(networks, hasSize(1)); FindNetworksResult result = networks.get(0); assertThat(result.getId(), equalTo(network.getId())); assertThat(result.getName(), equalTo(network.getName())); assertThat(result.getProjectName(), equalTo(project.getName())); assertThat(result.getState(), equalTo(network.getState())); assertThat(result.isShared(), equalTo(network.isIsShared())); assertThat(result.getSubnets(), contains("5.255.255.0/24")); }