Search in sources :

Example 16 with Fault

use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.

the class AbstractBackendCpuProfilesResourceTest method testListFailure.

@Override
@Test
public void testListFailure() throws Exception {
    setUpCpuProfilesQueryExpectations(FAILURE);
    UriInfo uriInfo = setUpUriExpectations(null);
    collection.setUriInfo(uriInfo);
    try {
        getCollection();
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        assertTrue(wae.getResponse().getEntity() instanceof Fault);
        assertEquals(mockl10n(FAILURE), ((Fault) wae.getResponse().getEntity()).getDetail());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Fault(org.ovirt.engine.api.model.Fault) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 17 with Fault

use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.

the class AbstractBackendDiskProfilesResourceTest method testListFailure.

@Override
@Test
public void testListFailure() throws Exception {
    setUpDiskProfilesQueryExpectations(FAILURE);
    UriInfo uriInfo = setUpUriExpectations(null);
    collection.setUriInfo(uriInfo);
    try {
        getCollection();
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        assertTrue(wae.getResponse().getEntity() instanceof Fault);
        assertEquals(mockl10n(FAILURE), ((Fault) wae.getResponse().getEntity()).getDetail());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Fault(org.ovirt.engine.api.model.Fault) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 18 with Fault

use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.

the class AbstractBackendNetworkAttachmentsResourceTest method testListFailure.

@Override
@Test
public void testListFailure() throws Exception {
    setUpNetworkAttachmentsQueryExpectations(FAILURE);
    UriInfo uriInfo = setUpUriExpectations(null);
    collection.setUriInfo(uriInfo);
    try {
        getCollection();
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        assertTrue(wae.getResponse().getEntity() instanceof Fault);
        assertEquals(mockl10n(FAILURE), ((Fault) wae.getResponse().getEntity()).getDetail());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Fault(org.ovirt.engine.api.model.Fault) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 19 with Fault

use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.

the class BackendFilesResourceTest method verifyFault.

@Override
protected void verifyFault(WebApplicationException wae, String reason, Throwable t) {
    assertEquals(BAD_REQUEST, wae.getResponse().getStatus());
    assertTrue(wae.getResponse().getEntity() instanceof Fault);
    Fault fault = (Fault) wae.getResponse().getEntity();
    assertEquals(reason, fault.getReason());
    assertNotNull(fault.getDetail());
    assertTrue("expected detail to include: " + t.getMessage(), fault.getDetail().contains(t.getMessage()));
}
Also used : Fault(org.ovirt.engine.api.model.Fault)

Example 20 with Fault

use of org.ovirt.engine.api.model.Fault in project ovirt-engine by oVirt.

the class AbstractBackendVnicProfilesResourceTest method testListFailure.

@Override
@Test
public void testListFailure() throws Exception {
    setUpVnicProfilesQueryExpectations(FAILURE);
    UriInfo uriInfo = setUpUriExpectations(null);
    collection.setUriInfo(uriInfo);
    try {
        getCollection();
        fail("expected WebApplicationException");
    } catch (WebApplicationException wae) {
        assertTrue(wae.getResponse().getEntity() instanceof Fault);
        assertEquals(mockl10n(FAILURE), ((Fault) wae.getResponse().getEntity()).getDetail());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) Fault(org.ovirt.engine.api.model.Fault) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

Fault (org.ovirt.engine.api.model.Fault)42 WebApplicationException (javax.ws.rs.WebApplicationException)17 Test (org.junit.Test)15 UriInfo (javax.ws.rs.core.UriInfo)14 IOException (java.io.IOException)4 URISyntaxException (java.net.URISyntaxException)3 Request (javax.ws.rs.core.Request)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Action (org.ovirt.engine.api.model.Action)2 CreationStatus (org.ovirt.engine.api.model.CreationStatus)2 AsyncTaskStatus (org.ovirt.engine.core.common.businessentities.AsyncTaskStatus)2 Response (javax.ws.rs.core.Response)1 Creation (org.ovirt.engine.api.model.Creation)1 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)1 Vm (org.ovirt.engine.api.model.Vm)1 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)1 InvalidValueException (org.ovirt.engine.api.utils.InvalidValueException)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 RemoveStorageDomainParameters (org.ovirt.engine.core.common.action.RemoveStorageDomainParameters)1 RunVmParams (org.ovirt.engine.core.common.action.RunVmParams)1