InstancesRepositoryImpl implements InstancesRepository { @Override public Set<String> addInstances(List<Instance> instances) { return executeAction( (apiProvider, is) -> apiProvider.getInstancesApi().launch(is), instances ); }  @Override List<FindInstancesResult> findInstances(FindInstancesRequest findInstancesRequest); @Override Map<String, Map<String, String>> getInstancesMetadata(FindInstancesRequest findInstancesRequest); @Override Set<String> addInstances(List<Instance> instances); @Override Set<String> startInstances(Collection<String> instanceIds); @Override Set<String> shutdownInstances(Collection<String> instanceIds); @Override Set<String> deleteInstances(Collection<String> instanceIds); @Override Set<String> renameInstances(Map<String, String> newNames); @Override Set<String> rebootInstances(Collection<String> instanceIds); @Override Set<String> rebuildInstances(String imageId, Collection<String> instanceIds); @Override Set<String> resizeInstances(String flavorId, Collection<String> instanceIds); @Override Set<String> pauseInstances(Collection<String> instanceIds); @Override Set<String> resumeInstances(Collection<String> instanceIds); @Override Set<String> suspendInstances(Collection<String> instanceIds); @Override Set<String> hardRebootInstances(Collection<String> instanceIds);  }
@Test public void testAddInstances() { Project project = EntityGenerator.getProject(); Instance instance = EntityGenerator.getInstance(); Image image = EntityGenerator.getImage(); Flavor flavor = EntityGenerator.getFlavor(); Network network = EntityGenerator.getNetwork(); Keypair keypair = EntityGenerator.getKeypair(); mockQueryRepository.addQueryResult(createMockProjectsResult(project)); mockQueryRepository.addQueryResult(createMockFlavorsResult(project, flavor)); mockQueryRepository.addQueryResult(createMockImagesResult(project, image)); mockQueryRepository.addQueryResult(createMockNetworksResult(project, network)); AddInstancesRequest addInstancesRequest = requestProvider.get(AddInstancesRequest.class) .withName(instance.getName()) .withImage(image.getName()) .withFlavor(flavor.getName()) .withNetwork(network.getName()) .withKeypair(keypair.getName()) .withProject(project.getName()); List<Instance> instances = addInstancesRequest.getPayload(); assertThat(instancesRepository.addInstances(instances), is(empty())); }