Search in sources :

Example 1 with ResourceService

use of com.cloud.resource.ResourceService in project cloudstack by apache.

the class UpdateHostPasswordCmdTest method setUp.

@Override
@Before
public void setUp() {
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    managementServer = Mockito.mock(ManagementService.class);
    resourceService = Mockito.mock(ResourceService.class);
    updateHostPasswordCmd = new UpdateHostPasswordCmd();
}
Also used : ManagementService(com.cloud.server.ManagementService) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) UpdateHostPasswordCmd(org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd) Before(org.junit.Before)

Example 2 with ResourceService

use of com.cloud.resource.ResourceService in project cloudstack by apache.

the class AddHostCmdTest method setUp.

@Override
@Before
public void setUp() {
    resourceService = Mockito.mock(ResourceService.class);
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    addHostCmd = new AddHostCmd() {
    };
}
Also used : ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) AddHostCmd(org.apache.cloudstack.api.command.admin.host.AddHostCmd) Before(org.junit.Before)

Example 3 with ResourceService

use of com.cloud.resource.ResourceService in project cloudstack by apache.

the class AddHostCmdTest method testExecuteForNullResult.

@Test
public void testExecuteForNullResult() {
    ResourceService resourceService = Mockito.mock(ResourceService.class);
    addHostCmd._resourceService = resourceService;
    try {
        Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(null);
    } catch (InvalidParameterValueException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DiscoveryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        addHostCmd.execute();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add host", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ResourceService(com.cloud.resource.ResourceService) DiscoveryException(com.cloud.exception.DiscoveryException) Test(org.junit.Test)

Example 4 with ResourceService

use of com.cloud.resource.ResourceService in project cloudstack by apache.

the class AddClusterCmdTest method testExecuteForResult.

@Test
public void testExecuteForResult() throws Exception {
    resourceService = Mockito.mock(ResourceService.class);
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    addClusterCmd._resourceService = resourceService;
    addClusterCmd._responseGenerator = responseGenerator;
    Cluster cluster = Mockito.mock(Cluster.class);
    Cluster[] clusterArray = new Cluster[] { cluster };
    Mockito.doReturn(Arrays.asList(clusterArray)).when(resourceService).discoverCluster(addClusterCmd);
    addClusterCmd.execute();
}
Also used : ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ResourceService(com.cloud.resource.ResourceService) Cluster(com.cloud.org.Cluster) Test(org.junit.Test)

Example 5 with ResourceService

use of com.cloud.resource.ResourceService in project cloudstack by apache.

the class AddClusterCmdTest method testExecuteForNullResult.

@Test
public void testExecuteForNullResult() {
    ResourceService resourceService = Mockito.mock(ResourceService.class);
    try {
        Mockito.when(resourceService.discoverCluster(addClusterCmd)).thenReturn(null);
    } catch (ResourceInUseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (DiscoveryException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    addClusterCmd._resourceService = resourceService;
    try {
        addClusterCmd.execute();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add cluster", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) ResourceInUseException(com.cloud.exception.ResourceInUseException) ResourceService(com.cloud.resource.ResourceService) DiscoveryException(com.cloud.exception.DiscoveryException) Test(org.junit.Test)

Aggregations

ResourceService (com.cloud.resource.ResourceService)6 Test (org.junit.Test)4 ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 DiscoveryException (com.cloud.exception.DiscoveryException)2 Before (org.junit.Before)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ResourceInUseException (com.cloud.exception.ResourceInUseException)1 Cluster (com.cloud.org.Cluster)1 ManagementService (com.cloud.server.ManagementService)1 AddHostCmd (org.apache.cloudstack.api.command.admin.host.AddHostCmd)1 UpdateHostPasswordCmd (org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd)1