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();
}
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() {
};
}
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());
}
}
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();
}
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());
}
}
Aggregations