ProjectsRepositoryImpl implements ProjectsRepository { @Override public List<FindProjectsResult> findProjects(FindProjectsRequest findProjectsRequest) { QueryResult projectsResult = queryRepository.query(findProjectsRequest.getPayload()); Data data = projectsResult.getData(); return data.getRows().stream() .map(r -> { ValueFormatter vf = new ValueFormatter(data, r); return new FindProjectsResult( vf.getString("id"), vf.getString("name"), vf.getString("cloud_id"), vf.getString("cloud_type"), vf.getString(new LinkedHashMap<String, String>() { { put("instances", "Instances"); put("vcpus", "Vcpus"); put("ram", "RAM"); put("disk", "Disk"); put("ips", "IPs"); put("security_groups", "Security groups"); put("volumes", "Volumes"); put("keypairs", "Keypairs"); } }) ); }) .collect(Collectors.toList()); } @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 testFindProjects() { Project project = EntityGenerator.getProject(); QueryResult queryResult = createMockProjectsResult(project); mockQueryRepository.addQueryResult(queryResult); FindProjectsRequest findProjectsRequest = requestProvider.get(FindProjectsRequest.class); List<FindProjectsResult> projects = projectsRepository.findProjects(findProjectsRequest); assertThat(projects, hasSize(1)); FindProjectsResult result = projects.get(0); assertThat(result.getId(), equalTo(project.getId())); assertThat(result.getName(), equalTo(project.getName())); assertThat(result.getCloudId(), equalTo(project.getCloudId())); assertThat(result.getCloudType(), equalTo(project.getCloudType())); assertThat(result.getQuota(), equalTo(String.format("Instances: %s", project.getQuota().getInstances()))); }