org.mockito.Mockito.any() - java examples

Here are the examples of the java api org.mockito.Mockito.any() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method and an HTTP GET request returns a failure
// response in JSON format, an UnexpectedException must be thrown.
@Test(expected = UnexpectedException.clreplaced)
public void testAttachRequestInstanceThrowUnexpectedException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD + VM_ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = AttachVolumeRequest.ATTACH_VOLUME_COMMAND;
    String id = FAKE_VOLUME_ID;
    String virtualMachineId = FAKE_VIRTUAL_MACHINE_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id, virtualMachineId);
    String response = getAttachmentResponse(JOB_STATUS_FAILURE, ATTACH_VOLUME_RESPONSE_KEY, null);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    // exercise
    this.plugin.requestInstance(this.attachmentOrder, this.cloudUser);
    PowerMockito.mockStatic(AttachVolumeResponse.clreplaced);
    PowerMockito.when(AttachVolumeResponse.fromJson(response)).thenCallRealMethod();
    // verify
    PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
    CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.eq(request), Mockito.eq(this.cloudUser));
    PowerMockito.verifyStatic(AttachVolumeResponse.clreplaced, VerificationModeFactory.times(1));
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method preplaceding some invalid argument, an
// FogbowException must be thrown.
@Test(expected = FogbowException.clreplaced)
public void testGetInstanceThrowFogbowException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_BAD_REQUEST, null));
    try {
        // exercise
        this.plugin.getInstance(attachmentOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method and an HTTP GET request returns a failure
// response in JSON format, an UnexpectedException must be thrown.
@Test(expected = UnexpectedException.clreplaced)
public void testDeleteInstanceThrowUnexpectedException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = DeleteVolumeRequest.DELETE_VOLUME_COMMAND;
    String id = FAKE_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id);
    boolean success = false;
    String response = getDeleteVolumeResponse(success);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    PowerMockito.mockStatic(DeleteVolumeResponse.clreplaced);
    PowerMockito.when(DeleteVolumeResponse.fromJson(response)).thenCallRealMethod();
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.deleteInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
        PowerMockito.verifyStatic(DeleteVolumeResponse.clreplaced, VerificationModeFactory.times(1));
        DeleteVolumeResponse.fromJson(Mockito.eq(response));
    }
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method, with a public IP order and
// cloud user valid, a client is invoked to request an address in the cloud, and
// mount a public IP instance.
@Test
public void testGetInstanceSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    String instanceId = FAKE_INSTANCE_ID;
    Address address = buildAddress(instanceId);
    describeAddressesMocked(address, client);
    PublicIpOrder publicIpOrder = Mockito.spy(new PublicIpOrder());
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    PublicIpInstance expected = createPublicIpInstance();
    // exercise
    PublicIpInstance publicIpInstance = this.plugin.getInstance(publicIpOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(client, Mockito.times(1)).describeAddresses(Mockito.any(DescribeAddressesRequest.clreplaced));
    replacedert.replacedertEquals(expected, publicIpInstance);
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the doCreateSecurityGroups method, and an error
// occurs during the request, an UnexpectedException will be thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testdoCreateSecurityGroupsUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.createSecurityGroup(Mockito.any(CreateSecurityGroupRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String allocationId = FAKE_ALLOCATION_ID;
    // exercise
    this.plugin.doCreateSecurityGroups(allocationId, client);
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When try to request instance with an ID of the volume and an ID of the virtual
// machine that do not exist, an InstanceNotFoundException must be thrown.
@Test(expected = InstanceNotFoundException.clreplaced)
public void testAttachRequestInstanceThrowNotFoundException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_NOT_FOUND, null));
    try {
        // exercise
        AttachmentOrder order = new AttachmentOrder(FAKE_VIRTUAL_MACHINE_ID, FAKE_VOLUME_ID, null);
        this.plugin.requestInstance(order, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method, an HTTP GET request must be made with a
// signed cloudUser, which returns a response in the JSON format for the retrieval of the
// VolumeInstance object.
@Test
public void testGetInstanceRequestSuccessful() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = GetVolumeRequest.LIST_VOLUMES_COMMAND;
    String id = FAKE_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id);
    String name = FAKE_NAME;
    String size = new Long(COMPATIBLE_SIZE * GIGABYTE).toString();
    String state = DEFAULT_STATE;
    String volume = getVolumeResponse(id, name, size, state);
    String response = getListVolumesResponse(volume);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    // exercise
    VolumeInstance recoveredInstance = this.plugin.getInstance(volumeOrder, this.cloudUser);
    // verify
    PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
    CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
    replacedert.replacedertEquals(id, recoveredInstance.getId());
    replacedert.replacedertEquals(name, recoveredInstance.getName());
    replacedert.replacedertEquals(COMPATIBLE_SIZE, recoveredInstance.getSize());
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(request, this.cloudUser);
}

19 View Complete Implementation : ComputeTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: Request a compute creation with an unauthenticated user. Check the response of request
// and the call of facade for create the compute.
@Test
public void testCreateComputeUnauthenticatedException() throws Exception {
    // set up
    Mockito.doThrow(new UnauthenticatedUserException()).when(this.facade).createCompute(Mockito.any(ComputeOrder.clreplaced), Mockito.anyString());
    RequestBuilder requestBuilder = createRequestBuilder(HttpMethod.POST, COMPUTE_ENDPOINT, getHttpHeaders(), CORRECT_BODY);
    // exercise
    MvcResult result = this.mockMvc.perform(requestBuilder).andReturn();
    // verify
    int expectedStatus = HttpStatus.UNAUTHORIZED.value();
    replacedert.replacedertEquals(expectedStatus, result.getResponse().getStatus());
    Mockito.verify(this.facade, Mockito.times(1)).createCompute(Mockito.any(ComputeOrder.clreplaced), Mockito.anyString());
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String awsConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + CLOUD_NAME + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.plugin = Mockito.spy(new AwsV2PublicIpPlugin(awsConfFilePath));
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method a HTTP GET request must be made with a
// signed cloudUser, returning the id of the Attachment.
@Test
public void testAttachRequestInstanceSuccessful() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD + VM_ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = AttachVolumeRequest.ATTACH_VOLUME_COMMAND;
    String id = FAKE_VOLUME_ID;
    String virtualMachineId = FAKE_VIRTUAL_MACHINE_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id, virtualMachineId);
    int status = JOB_STATUS_COMPLETE;
    String jobId = FAKE_INSTANCE_ID;
    String attributeKey = ATTACH_VOLUME_RESPONSE_KEY;
    String response = getAttachmentResponse(status, attributeKey, jobId);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    // exercise
    String volumeId = this.plugin.requestInstance(this.attachmentOrder, this.cloudUser);
    // verify
    PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
    CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.eq(request), Mockito.eq(this.cloudUser));
    replacedert.replacedertEquals(FAKE_INSTANCE_ID, volumeId);
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method, with a compute order and
// cloud user valid, and an error will occur, the UnexpectedException will be
// thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testDeleteInstanceUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.doThrow(Ec2Exception.clreplaced).when(client).terminateInstances(Mockito.any(TerminateInstancesRequest.clreplaced));
    ComputeOrder computeOrder = createComputeOrder(null);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    // exercise
    this.plugin.deleteInstance(computeOrder, cloudUser);
}

19 View Complete Implementation : AwsV2NetworkPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the handleSecurityIssues method, without a valid
// security group request, the UnexpectedException will be thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testHandleSecurityIssuesUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.createSecurityGroup(Mockito.any(CreateSecurityGroupRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String cidr = FAKE_CIDR_ADDRESS;
    String subnetId = FAKE_SUBNET_ID;
    // exercise
    this.plugin.handleSecurityIssues(cidr, subnetId, client);
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String awsConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + CLOUD_NAME + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.plugin = Mockito.spy(new AwsV2ComputePlugin(awsConfFilePath));
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
}

19 View Complete Implementation : OpenNebulaAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method, with the instance ID and a
// valid token, a set of images will be loaded and the specific instance of the
// image must be loaded.
@Test
public void testGetInstanceSuccessful() throws FogbowException {
    // set up
    ImagePool imagePool = Mockito.mock(ImagePool.clreplaced);
    PowerMockito.mockStatic(OpenNebulaClientUtil.clreplaced);
    Mockito.when(OpenNebulaClientUtil.getImagePool(Mockito.any(Client.clreplaced))).thenReturn(imagePool);
    int diskId = 1;
    Image image = Mockito.mock(Image.clreplaced);
    Mockito.when(imagePool.getById(diskId)).thenReturn(image);
    String imageDevice = FAKE_DEVICE;
    Mockito.when(image.xpath(DEFAULT_DEVICE_PREFIX)).thenReturn(imageDevice);
    Mockito.when(image.stateString()).thenReturn(IMAGE_STATE_READY);
    CloudUser cloudUser = createCloudUser();
    // exercise
    this.plugin.getInstance(attachmentOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(OpenNebulaClientUtil.clreplaced, VerificationModeFactory.times(1));
    OpenNebulaClientUtil.createClient(Mockito.anyString(), Mockito.anyString());
    PowerMockito.verifyStatic(OpenNebulaClientUtil.clreplaced, VerificationModeFactory.times(1));
    OpenNebulaClientUtil.getImagePool(Mockito.any(Client.clreplaced));
    Mockito.verify(imagePool, Mockito.times(1)).getById(Mockito.eq(diskId));
    Mockito.verify(image, Mockito.times(1)).xpath(Mockito.eq(DEFAULT_DEVICE_PREFIX));
    Mockito.verify(image, Mockito.times(1)).stateString();
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method with a user without permission, an
// UnauthorizedRequestException must be thrown.
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testGetInstanceThrowUnauthorizedRequestException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    try {
        // exercise
        this.plugin.getInstance(attachmentOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When try to get an instance with an ID that does not exist, an
// InstanceNotFoundException must be thrown.
@Test(expected = InstanceNotFoundException.clreplaced)
public void testGetInstanceThrowNotFoundException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_NOT_FOUND, null));
    try {
        // exercise
        this.plugin.getInstance(attachmentOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method, with a compute order and
// cloud user valid, the instance in the cloud must be terminated.
@Test
public void testDeleteInstanceSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    ComputeOrder computeOrder = createComputeOrder(null);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    // exercise
    this.plugin.deleteInstance(computeOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(client, Mockito.times(1)).terminateInstances(Mockito.any(TerminateInstancesRequest.clreplaced));
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getFlavorsByRequirements method, with a
// requirements map, it must filter the possibilities according to that map,
// returning the corresponding results.
@Test
public void testGetFlavorsByRequirementsSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    this.plugin.updateHardwareRequirements(cloudUser);
    Map<String, String> requirements = new HashMap<String, String>();
    requirements.put(AwsV2ComputePlugin.STORAGE_REQUIREMENT, "1x75-SSD-NVMe");
    requirements.put(AwsV2ComputePlugin.BANDWIDTH_REQUIREMENT, "<3500");
    requirements.put(AwsV2ComputePlugin.PERFORMANCE_REQUIREMENT, "<10");
    requirements.put(AwsV2ComputePlugin.PROCESSOR_REQUIREMENT, "Intel_Xeon_Platinum_8175_3.1GHz");
    ComputeOrder computeOrder = createComputeOrder(requirements);
    int expected = AMOUNT_SSD_STORAGE;
    // exercise
    TreeSet<AwsHardwareRequirements> flavors = this.plugin.getFlavorsByRequirements(computeOrder.getRequirements());
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(this.plugin, Mockito.times(4)).filterFlavors(Mockito.any(), Mockito.any());
    replacedert.replacedertEquals(expected, flavors.size());
}

19 View Complete Implementation : CloudStackComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String cloudStackConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + CLOUD_NAME + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.properties = PropertiesUtil.readProperties(cloudStackConfFilePath);
    this.defaultNetworkId = this.properties.getProperty(CloudStackPublicIpPlugin.DEFAULT_NETWORK_ID_KEY);
    this.launchCommandGeneratorMock = Mockito.mock(LaunchCommandGenerator.clreplaced);
    this.client = Mockito.mock(CloudStackHttpClient.clreplaced);
    this.plugin = new CloudStackComputePlugin(cloudStackConfFilePath);
    this.plugin.setClient(this.client);
    this.plugin.setLaunchCommandGenerator(this.launchCommandGeneratorMock);
    this.fakeZoneId = this.properties.getProperty(CloudStackComputePlugin.ZONE_ID_KEY);
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the doDescribeInstance method, and an error occurs
// during the request, an UnexpectedException will be thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testDoDescribeInstanceUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.describeInstances(Mockito.any(DescribeInstancesRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String instanceId = FAKE_INSTANCE_ID;
    // exercise
    this.plugin.doDescribeInstance(instanceId, client);
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getFlavorsByRequirements method with a
// requirements map containing the most demanding graphics emulation attributes,
// it must filter the possibilities according to that map and return a set with
// an instance type with the highest performance of this level.
@Test
public void testGetFlavorsByRequirementsWithGraphicEmulationAtribute() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    this.plugin.updateHardwareRequirements(cloudUser);
    Map<String, String> requirements = new HashMap<String, String>();
    requirements.put(AwsV2ComputePlugin.PROCESSOR_REQUIREMENT, "Intel_Xeon_E5-2686_v4_2.3GHz");
    requirements.put(AwsV2ComputePlugin.GRAPHIC_EMULATION_REQUIREMENT, "8");
    ComputeOrder computeOrder = createComputeOrder(requirements);
    String expected = InstanceType.F1_16_XLARGE.toString();
    // exercise
    TreeSet<AwsHardwareRequirements> flavors = this.plugin.getFlavorsByRequirements(computeOrder.getRequirements());
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(this.plugin, Mockito.times(2)).filterFlavors(Mockito.any(), Mockito.any());
    replacedert.replacedertEquals(expected, flavors.first().getName());
}

19 View Complete Implementation : OpenNebulaPublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String opennebulaConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + OPENNEBULA_CLOUD_NAME_DIRECTORY + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.plugin = Mockito.spy(new OpenNebulaPuplicIpPlugin(opennebulaConfFilePath));
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
    this.publicIpOrder = createPublicIpOrder();
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method with a unauthenticated user, an
// UnauthenticatedUserException must be thrown.
@Test(expected = UnauthenticatedUserException.clreplaced)
public void testAttachRequestInstanceThrowUnauthenticatedUserException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_UNAUTHORIZED, null));
    try {
        // exercise
        AttachmentOrder order = new AttachmentOrder(FAKE_VIRTUAL_MACHINE_ID, FAKE_VOLUME_ID, null);
        this.plugin.requestInstance(order, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method and an HTTP GET request returns a failure
// response in JSON format, an UnexpectedException must be thrown.
@Test(expected = UnexpectedException.clreplaced)
public void testDeleteInstanceThrowUnexpectedException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = DetachVolumeRequest.DETACH_VOLUME_COMMAND;
    String id = FAKE_VOLUME_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id);
    String response = getAttachmentResponse(JOB_STATUS_FAILURE, DETACH_VOLUME_RESPONSE_KEY, null);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    PowerMockito.mockStatic(DetachVolumeResponse.clreplaced);
    PowerMockito.when(DetachVolumeResponse.fromJson(response)).thenCallRealMethod();
    // exercise
    this.plugin.deleteInstance(attachmentOrder, this.cloudUser);
    // verify
    PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
    CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(request, cloudUser);
    PowerMockito.verifyStatic(DetachVolumeResponse.clreplaced, VerificationModeFactory.times(1));
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the updateHardwareRequirements method, with a valid
// cloud user, there will be updating the set of available flavors.
@Test
public void testUpdateHardwareRequirementsSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    int expected = this.plugin.loadLinesFromFlavorFile().size() - 1;
    // exercise
    this.plugin.updateHardwareRequirements(cloudUser);
    // verify
    replacedert.replacedertEquals(expected, this.plugin.getFlavors().size());
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method preplaceding some invalid argument, an
// FogbowException must be thrown.
@Test(expected = FogbowException.clreplaced)
public void testAttachRequestInstanceThrowFogbowException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_BAD_REQUEST, null));
    try {
        // exercise
        AttachmentOrder order = new AttachmentOrder(FAKE_VIRTUAL_MACHINE_ID, FAKE_VOLUME_ID, null);
        this.plugin.requestInstance(order, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method with a user without permission, an
// UnauthorizedRequestException must be thrown.
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testGetInstanceThrowUnauthorizedRequestException() throws UnexpectedException, FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.getInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method with a user without permission, an
// UnauthorizedRequestException must be thrown.
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testCreateRequestInstanceThrowUnauthorizedRequestException() throws FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    try {
        // exercise
        VolumeOrder order = new VolumeOrder(null, FAKE_MEMBER, FAKE_MEMBER, "default", FAKE_NAME, CUSTOMIZED_SIZE);
        this.plugin.requestInstance(order, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method and an HTTP GET request returns a failure
// response in JSON format, an UnexpectedException must be thrown.
@Test(expected = UnexpectedException.clreplaced)
public void testGetInstanceThrowUnexpectedException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    String urlFormat = REQUEST_FORMAT + RESPONSE_FORMAT + ID_FIELD;
    String baseEndpoint = getBaseEndpointFromCloudStackConf();
    String command = GetVolumeRequest.LIST_VOLUMES_COMMAND;
    String id = FAKE_ID;
    String jsonFormat = JSON_FORMAT;
    String request = String.format(urlFormat, baseEndpoint, command, jsonFormat, id);
    String volume = EMPTY_INSTANCE;
    String response = getListVolumesResponse(volume);
    Mockito.when(this.client.doGetRequest(request, this.cloudUser)).thenReturn(response);
    PowerMockito.mockStatic(GetVolumeResponse.clreplaced);
    PowerMockito.when(GetVolumeResponse.fromJson(response)).thenCallRealMethod();
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.getInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
        PowerMockito.verifyStatic(GetVolumeResponse.clreplaced, VerificationModeFactory.times(1));
        GetVolumeResponse.fromJson(Mockito.eq(response));
    }
}

19 View Complete Implementation : AwsV2NetworkPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method, with a network order and
// cloud user valid, a client is invoked to request a network in the cloud, and
// mount a network instance.
@Test
public void testGetInstanceSucessfull() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    String vpcId = FAKE_VPC_ID;
    createMockedRouteTables(vpcId, client);
    mockDescribeSubnets(client);
    NetworkOrder networkOrder = Mockito.spy(new NetworkOrder());
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    NetworkInstance expected = createNetworkInstances();
    // exercise
    NetworkInstance instance = this.plugin.getInstance(networkOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(client, Mockito.times(1)).describeSubnets(Mockito.any(DescribeSubnetsRequest.clreplaced));
    Mockito.verify(client, Mockito.times(1)).describeRouteTables();
    replacedert.replacedertEquals(expected, instance);
}

19 View Complete Implementation : OpenNebulaAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String opennebulaConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + CLOUD_NAME + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.plugin = Mockito.spy(new OpenNebulaAttachmentPlugin(opennebulaConfFilePath));
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
    this.attachmentOrder = createAttachmentOrder();
}

19 View Complete Implementation : OpenNebulaAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method, with the fake instance ID
// or an invalid token, an error will occur and an InvalidParameterException
// will be thrown.
@Test(expected = InvalidParameterException.clreplaced)
public void testRequestInstanceUnsuccessful() throws FogbowException {
    // set up
    VirtualMachine virtualMachine = Mockito.mock(VirtualMachine.clreplaced);
    PowerMockito.mockStatic(OpenNebulaClientUtil.clreplaced);
    BDDMockito.given(OpenNebulaClientUtil.getVirtualMachine(Mockito.any(Client.clreplaced), Mockito.anyString())).willReturn(virtualMachine);
    String template = generateAttachmentTemplate();
    OneResponse response = Mockito.mock(OneResponse.clreplaced);
    Mockito.when(virtualMachine.diskAttach(Mockito.contains(template))).thenReturn(response);
    Mockito.when(response.isError()).thenReturn(true);
    CloudUser cloudUser = createCloudUser();
    // exercise
    this.plugin.requestInstance(attachmentOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(OpenNebulaClientUtil.clreplaced, VerificationModeFactory.times(1));
    OpenNebulaClientUtil.createClient(Mockito.anyString(), Mockito.anyString());
    PowerMockito.verifyStatic(OpenNebulaClientUtil.clreplaced, VerificationModeFactory.times(1));
    OpenNebulaClientUtil.getVirtualMachine(Mockito.any(Client.clreplaced), Mockito.anyString());
    Mockito.verify(virtualMachine, Mockito.times(1)).diskAttach(Mockito.eq(template));
}

19 View Complete Implementation : CloudStackNetworkPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: an UnauthorizedRequestException should be thrown when the user tries to delete
// a network and was not allowed to do that
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testUnauthorizedExceptionIsThrownWhenOrchestratorForbids() throws FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    NetworkOrder networkOrder = new NetworkOrder();
    networkOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.deleteInstance(networkOrder, FAKE_CLOUD_USER);
    } finally {
        // verify
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method with a user without permission, an
// UnauthorizedRequestException must be thrown.
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testDeleteInstanceThrowUnauthorizedRequestException() throws UnexpectedException, FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.getInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method with a unauthenticated user, an
// UnauthenticatedUserException must be thrown.
@Test(expected = UnauthenticatedUserException.clreplaced)
public void testDeleteInstanceThrowUnauthenticatedUserException() throws UnexpectedException, FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_UNAUTHORIZED, null));
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.getInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method with a unauthenticated user, an
// UnauthenticatedUserException must be thrown.
@Test(expected = UnauthenticatedUserException.clreplaced)
public void testCreateRequestInstanceThrowUnauthenticatedUserException() throws FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_UNAUTHORIZED, null));
    try {
        // exercise
        VolumeOrder order = new VolumeOrder(null, FAKE_MEMBER, FAKE_MEMBER, "default", FAKE_NAME, CUSTOMIZED_SIZE);
        this.plugin.requestInstance(order, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getFlavorsByRequirements method, with an empty
// map, there will be no filter to limit the results, returning all the flavors
// obtained in the last update.
@Test
public void testGetFlavorsByRequirementsWithEmptyMap() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    this.plugin.updateHardwareRequirements(cloudUser);
    Map<String, String> requirements = new HashMap<String, String>();
    ComputeOrder computeOrder = createComputeOrder(requirements);
    int expected = this.plugin.loadLinesFromFlavorFile().size() - 1;
    // exercise
    TreeSet<AwsHardwareRequirements> flavors = this.plugin.getFlavorsByRequirements(computeOrder.getRequirements());
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    replacedert.replacedertEquals(expected, flavors.size());
}

19 View Complete Implementation : CloudStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method preplaceding some invalid argument, an
// FogbowException must be thrown.
@Test(expected = FogbowException.clreplaced)
public void testGetInstanceThrowFogbowException() throws UnexpectedException, FogbowException, HttpResponseException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_BAD_REQUEST, null));
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_ID);
    try {
        // exercise
        this.plugin.getInstance(volumeOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the doReleaseAddresses method, and an error
// occurs during the request, an UnexpectedException will be thrown.
@Test(expected = UnexpectedException.clreplaced)
public void testDoReleaseAddressesUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.releaseAddress(Mockito.any(ReleaseAddressRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String allocationId = FAKE_ALLOCATION_ID;
    // exercise
    this.plugin.doReleaseAddresses(allocationId, client);
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getFlavorsByRequirements method with a
// requirements map containing high-level graphical attributes, it must filter
// the possibilities according to that map and return a set with a
// higher-performing instance type.
@Test
public void testGetFlavorsByRequirementsWithHighPerformanceGraphic() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    this.plugin.updateHardwareRequirements(cloudUser);
    Map<String, String> requirements = new HashMap<String, String>();
    requirements.put(AwsV2ComputePlugin.GRAPHIC_SHARING_REQUIREMENT, "NVLink");
    requirements.put(AwsV2ComputePlugin.GRAPHIC_PROCESSOR_REQUIREMENT, "8");
    requirements.put(AwsV2ComputePlugin.GRAPHIC_MEMORY_REQUIREMENT, "256");
    ComputeOrder computeOrder = createComputeOrder(requirements);
    String expected = InstanceType.P3_DN_24_XLARGE.toString();
    // exercise
    TreeSet<AwsHardwareRequirements> flavors = this.plugin.getFlavorsByRequirements(computeOrder.getRequirements());
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(1));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(this.plugin, Mockito.times(3)).filterFlavors(Mockito.any(), Mockito.any());
    replacedert.replacedertEquals(expected, flavors.first().getName());
}

19 View Complete Implementation : AwsV2NetworkPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
@Before
public void setUp() {
    String awsConfFilePath = HomeDir.getPath() + SystemConstants.CLOUDS_CONFIGURATION_DIRECTORY_NAME + File.separator + CLOUD_NAME + File.separator + SystemConstants.CLOUD_SPECIFICITY_CONF_FILE_NAME;
    this.plugin = Mockito.spy(new AwsV2NetworkPlugin(awsConfFilePath));
    this.sharedOrderHolders = Mockito.mock(SharedOrderHolders.clreplaced);
    PowerMockito.mockStatic(SharedOrderHolders.clreplaced);
    BDDMockito.given(SharedOrderHolders.getInstance()).willReturn(this.sharedOrderHolders);
    Mockito.when(this.sharedOrderHolders.getOrdersList(Mockito.any(OrderState.clreplaced))).thenReturn(new SynchronizedDoublyLinkedList<>());
    Mockito.when(this.sharedOrderHolders.getActiveOrdersMap()).thenReturn(new HashMap<>());
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the requestInstance method, with a compute order and
// cloud user valid, a client is invoked to run instances, returning its ID.
@Test
public void testRequestInstanceSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse response = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(response);
    mockRunningInstance(client);
    ComputeOrder computeOrder = createComputeOrder(null);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    // exercise
    this.plugin.requestInstance(computeOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(2));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(client, Mockito.times(1)).runInstances(Mockito.any(RunInstancesRequest.clreplaced));
    Mockito.verify(client, Mockito.times(1)).createTags(Mockito.any(CreateTagsRequest.clreplaced));
    Mockito.verify(this.plugin, Mockito.times(1)).loadNetworkInterfaces(Mockito.anyList());
    Mockito.verify(this.plugin, Mockito.times(1)).findSmallestFlavor(Mockito.eq(computeOrder), Mockito.any(AwsV2User.clreplaced));
}

19 View Complete Implementation : CloudStackAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method with a user without permission, an
// UnauthorizedRequestException must be thrown.
@Test(expected = UnauthorizedRequestException.clreplaced)
public void testDeleteInstanceThrowUnauthorizedRequestException() throws HttpResponseException, FogbowException {
    // set up
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced))).thenThrow(new HttpResponseException(HttpStatus.SC_FORBIDDEN, null));
    try {
        // exercise
        this.plugin.deleteInstance(attachmentOrder, this.cloudUser);
    } finally {
        // verify
        PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(1));
        CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
        Mockito.verify(this.client, Mockito.times(1)).doGetRequest(Mockito.anyString(), Mockito.any(CloudStackUser.clreplaced));
    }
}

19 View Complete Implementation : AwsV2NetworkPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the doCreateSubnetResquests method, without a valid
// subnet request, the UnexpectedException will be thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testDoCreateSubnetResquestsUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.createSubnet(Mockito.any(CreateSubnetRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String name = null;
    CreateSubnetRequest request = null;
    // exercise
    this.plugin.doCreateSubnetResquests(name, request, client);
}

19 View Complete Implementation : OpenStackVolumePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: Check if the request in deleteInstance() is executed properly with the right parameters.
@Test
public void removeInstance() throws FogbowException, HttpResponseException {
    // set up
    Mockito.doNothing().when(this.client).doDeleteRequest(Mockito.anyString(), Mockito.any(OpenStackV3User.clreplaced));
    VolumeOrder volumeOrder = new VolumeOrder();
    volumeOrder.setInstanceId(FAKE_INSTANCE_ID);
    // exercise
    this.openStackVolumePlugin.deleteInstance(volumeOrder, this.openStackV3Token);
    // verify
    Mockito.verify(this.client).doDeleteRequest(Mockito.anyString(), Mockito.any(OpenStackV3User.clreplaced));
}

19 View Complete Implementation : CloudStackComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// Test case: when getting virtual machine, the token should be signed and two HTTP GET requests should be made:
// one to retrieve the virtual machine from the cloudstack compute service and another to retrieve that vm disk
// size from the cloudstack volume service. Finally, valid compute instance should be returned from those
// requests results.
@Test
public void testGetInstance() throws FogbowException, HttpResponseException {
    // set up
    String endpoint = getBaseEndpointFromCloudStackConf();
    String computeCommand = GetVirtualMachineRequest.LIST_VMS_COMMAND;
    String volumeCommand = GetVolumeRequest.LIST_VOLUMES_COMMAND;
    List<String> ipAddresses = new ArrayList<>();
    ipAddresses.add(FAKE_ADDRESS);
    String expectedComputeRequestUrl = generateExpectedUrl(endpoint, computeCommand, RESPONSE_KEY, JSON, ID_KEY, FAKE_ID);
    String expectedVolumeRequestUrl = generateExpectedUrl(endpoint, volumeCommand, RESPONSE_KEY, JSON, VIRTUAL_MACHINE_ID_KEY, FAKE_ID, TYPE_KEY, FAKE_TYPE);
    String successfulComputeResponse = getVirtualMachineResponse(FAKE_ID, FAKE_INSTANCE_NAME, FAKE_STATE, FAKE_CPU_NUMBER, FAKE_MEMORY, FAKE_ADDRESS);
    double value = Integer.valueOf(FAKE_DISK) * Math.pow(1024, 3);
    String fakeDiskInBytes = new Double(value).toString();
    String volumeResponse = getVolumeResponse(FAKE_ID, FAKE_INSTANCE_NAME, fakeDiskInBytes, FAKE_STATE);
    String successfulVolumeResponse = getListVolumesResponse(volumeResponse);
    PowerMockito.mockStatic(CloudStackUrlUtil.clreplaced);
    PowerMockito.when(CloudStackUrlUtil.createURIBuilder(Mockito.anyString(), Mockito.anyString())).thenCallRealMethod();
    Mockito.when(this.client.doGetRequest(expectedComputeRequestUrl, FAKE_TOKEN)).thenReturn(successfulComputeResponse);
    Mockito.when(this.client.doGetRequest(expectedVolumeRequestUrl, FAKE_TOKEN)).thenReturn(successfulVolumeResponse);
    ComputeOrder computeOrder = new ComputeOrder();
    computeOrder.setInstanceId(FAKE_ID);
    // exercise
    ComputeInstance retrievedInstance = this.plugin.getInstance(computeOrder, FAKE_TOKEN);
    // verify
    replacedert.replacedertEquals(FAKE_ID, retrievedInstance.getId());
    replacedert.replacedertEquals(FAKE_INSTANCE_NAME, retrievedInstance.getName());
    replacedert.replacedertEquals(CloudStackStateMapper.READY_STATUS, retrievedInstance.getCloudState());
    replacedert.replacedertEquals(FAKE_CPU_NUMBER, String.valueOf(retrievedInstance.getvCPU()));
    replacedert.replacedertEquals(FAKE_MEMORY, String.valueOf(retrievedInstance.getMemory()));
    replacedert.replacedertEquals(FAKE_DISK, String.valueOf(retrievedInstance.getDisk()));
    replacedert.replacedertEquals(ipAddresses, retrievedInstance.getIpAddresses());
    PowerMockito.verifyStatic(CloudStackUrlUtil.clreplaced, VerificationModeFactory.times(2));
    CloudStackUrlUtil.sign(Mockito.any(URIBuilder.clreplaced), Mockito.anyString());
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(expectedComputeRequestUrl, FAKE_TOKEN);
    Mockito.verify(this.client, Mockito.times(1)).doGetRequest(expectedVolumeRequestUrl, FAKE_TOKEN);
}

19 View Complete Implementation : AttachmentTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: Request an attachment creation with request body without property values and test fail return
// Check if the correct http status is being sent in the request response
@Test
public void testPostAttachmentBodyWithoutProperties() throws Exception {
    // set up
    RequestBuilder requestBuilder = createRequestBuilder(HttpMethod.POST, ATTACHMENT_ENDPOINT, getHttpHeaders(), BODY_WITH_EMPTY_PROPERTIES);
    // exercise: Make the request
    MvcResult result = this.mockMvc.perform(requestBuilder).andReturn();
    // verify
    int expectedStatus = HttpStatus.UNSUPPORTED_MEDIA_TYPE.value();
    replacedert.replacedertEquals(expectedStatus, result.getResponse().getStatus());
    Mockito.verify(this.facade, Mockito.times(1)).createAttachment(Mockito.any(AttachmentOrder.clreplaced), Mockito.anyString());
}

19 View Complete Implementation : AwsV2PublicIpPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the doCreateTagsRequests method, without a valid
// tag request, an UnexpectedException will be thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testDoCreateTagsRequestsUnsuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    Mockito.when(client.createTags(Mockito.any(CreateTagsRequest.clreplaced))).thenThrow(SdkClientException.builder().build());
    String key = null;
    String value = null;
    String resourceId = null;
    // exercise
    this.plugin.doCreateTagsRequests(key, value, resourceId, client);
}

19 View Complete Implementation : OpenNebulaAttachmentPluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the deleteInstance method and unable to disconnect
// the virtual machine, to detach the resource, an UnexpectedException will be
// thrown.
// verify
@Test(expected = UnexpectedException.clreplaced)
public void testDeleteInstanceThrowUnexpectedException() throws FogbowException {
    // set up
    String virtualMachineId = FAKE_VIRTUAL_MACHINE_ID;
    VirtualMachine virtualMachine = Mockito.mock(VirtualMachine.clreplaced);
    PowerMockito.mockStatic(OpenNebulaClientUtil.clreplaced);
    BDDMockito.given(OpenNebulaClientUtil.getVirtualMachine(Mockito.any(Client.clreplaced), Mockito.eq(virtualMachineId))).willReturn(virtualMachine);
    Mockito.when(virtualMachine.stateStr()).thenReturn(VIRTUAL_MACHINE_STATE_FAIL);
    CloudUser cloudUser = createCloudUser();
    // exercise
    this.plugin.deleteInstance(attachmentOrder, cloudUser);
}

19 View Complete Implementation : AwsV2ComputePluginTest.java
Copyright GNU General Public License v3.0
Author : fogbow
// test case: When calling the getInstance method, with a valid compute order
// and cloud user, a client is called to request an instance in the cloud and
// mount this instance.
@Test
public void testGetInstanceSuccessful() throws FogbowException {
    // set up
    Ec2Client client = Mockito.mock(Ec2Client.clreplaced);
    PowerMockito.mockStatic(AwsV2ClientUtil.clreplaced);
    BDDMockito.given(AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString())).willReturn(client);
    DescribeImagesResponse imageResponse = createDescribeImage();
    Mockito.when(client.describeImages(Mockito.any(DescribeImagesRequest.clreplaced))).thenReturn(imageResponse);
    AwsV2User cloudUser = Mockito.mock(AwsV2User.clreplaced);
    this.plugin.updateHardwareRequirements(cloudUser);
    DescribeVolumesResponse volumeResponse = createVolumeResponse();
    Mockito.when(client.describeVolumes(Mockito.any(DescribeVolumesRequest.clreplaced))).thenReturn(volumeResponse);
    DescribeInstancesResponse instanceResponse = createInstanceResponse();
    Mockito.when(client.describeInstances(Mockito.any(DescribeInstancesRequest.clreplaced))).thenReturn(instanceResponse);
    Mockito.when(this.plugin.getRandomUUID()).thenReturn(FAKE_INSTANCE_ID);
    ComputeOrder computeOrder = createComputeOrder(null);
    // exercise
    this.plugin.getInstance(computeOrder, cloudUser);
    // verify
    PowerMockito.verifyStatic(AwsV2ClientUtil.clreplaced, VerificationModeFactory.times(3));
    AwsV2ClientUtil.createEc2Client(Mockito.anyString(), Mockito.anyString());
    Mockito.verify(client, Mockito.times(1)).describeInstances(Mockito.any(DescribeInstancesRequest.clreplaced));
    Mockito.verify(this.plugin, times(1)).getInstanceReservation(Mockito.any(DescribeInstancesResponse.clreplaced));
    Mockito.verify(this.plugin, times(1)).getInstanceVolumes(Mockito.any(Instance.clreplaced), Mockito.eq(client));
    Mockito.verify(this.plugin, Mockito.times(1)).mountComputeInstance(Mockito.any(Instance.clreplaced), Mockito.anyList());
}