Search in sources :

Example 1 with GlanceTask

use of org.openstack4j.openstack.image.v2.domain.GlanceTask in project cloudbreak by hortonworks.

the class OpenStackImageImageImporterTest method testImportNoStatus.

@Test(expected = CloudConnectorException.class)
public void testImportNoStatus() {
    try {
        GlanceTask task = Mockito.mock(GlanceTask.class);
        when(task.getStatus()).thenReturn(null);
        when(task.getMessage()).thenReturn("USEFUL ERRROR MESSAGE");
        when(taskService.create(any())).thenReturn(task);
        underTest.importImage(osClient, "myimage");
    } catch (CloudConnectorException e) {
        Assert.assertEquals("Import of myimage did not return any status, message: USEFUL ERRROR MESSAGE", e.getMessage());
        throw e;
    }
}
Also used : CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) GlanceTask(org.openstack4j.openstack.image.v2.domain.GlanceTask) Test(org.junit.Test)

Example 2 with GlanceTask

use of org.openstack4j.openstack.image.v2.domain.GlanceTask in project cloudbreak by hortonworks.

the class OpenStackImageImageImporterTest method testImportFailure.

@Test(expected = CloudConnectorException.class)
public void testImportFailure() {
    try {
        GlanceTask task = Mockito.mock(GlanceTask.class);
        when(task.getStatus()).thenReturn(Task.TaskStatus.FAILURE);
        when(task.getMessage()).thenReturn("USEFUL ERRROR MESSAGE");
        when(taskService.create(any())).thenReturn(task);
        underTest.importImage(osClient, "myimage");
    } catch (CloudConnectorException e) {
        Assert.assertEquals("Import of myimage failed with status: FAILURE, message: USEFUL ERRROR MESSAGE", e.getMessage());
        throw e;
    }
}
Also used : CloudConnectorException(com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException) GlanceTask(org.openstack4j.openstack.image.v2.domain.GlanceTask) Test(org.junit.Test)

Example 3 with GlanceTask

use of org.openstack4j.openstack.image.v2.domain.GlanceTask in project cloudbreak by hortonworks.

the class OpenStackImageImageImporterTest method testImportSuccess.

@Test
public void testImportSuccess() {
    GlanceTask task = Mockito.mock(GlanceTask.class);
    when(task.getStatus()).thenReturn(Task.TaskStatus.SUCCESS);
    when(taskService.create(any())).thenReturn(task);
    underTest.importImage(osClient, "myimage");
}
Also used : GlanceTask(org.openstack4j.openstack.image.v2.domain.GlanceTask) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 GlanceTask (org.openstack4j.openstack.image.v2.domain.GlanceTask)3 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)2