Search in sources :

Example 1 with ServiceMethodException

use of org.nhindirect.common.rest.exceptions.ServiceMethodException in project nhin-d by DirectProject.

the class UnsecuredServiceRequestBase_interpretResponseTest method testInterpretResponseTest_404Status_assertServiceMethodException.

@Test
public void testInterpretResponseTest_404Status_assertServiceMethodException() throws Exception {
    MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
    HttpResponse resp = mock(HttpResponse.class);
    boolean exceptionOccured = false;
    try {
        req.interpretResponse(404, resp);
    } catch (ServiceMethodException e) {
        assertEquals(404, e.getResponseCode());
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : HttpResponse(org.apache.http.HttpResponse) ServiceMethodException(org.nhindirect.common.rest.exceptions.ServiceMethodException) Test(org.junit.Test)

Example 2 with ServiceMethodException

use of org.nhindirect.common.rest.exceptions.ServiceMethodException in project nhin-d by DirectProject.

the class UnsecuredServiceRequestBase_interpretResponseTest method testInterpretResponseTest_400Status_assertServiceMethodException.

@Test
public void testInterpretResponseTest_400Status_assertServiceMethodException() throws Exception {
    MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
    HttpResponse resp = mock(HttpResponse.class);
    boolean exceptionOccured = false;
    try {
        req.interpretResponse(400, resp);
    } catch (ServiceMethodException e) {
        assertEquals(400, e.getResponseCode());
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : HttpResponse(org.apache.http.HttpResponse) ServiceMethodException(org.nhindirect.common.rest.exceptions.ServiceMethodException) Test(org.junit.Test)

Example 3 with ServiceMethodException

use of org.nhindirect.common.rest.exceptions.ServiceMethodException in project nhin-d by DirectProject.

the class UnsecuredServiceRequestBase_interpretResponseTest method testInterpretResponseTest_500Status_assertServiceMethodException.

@Test
public void testInterpretResponseTest_500Status_assertServiceMethodException() throws Exception {
    MockServiceRequest req = new MockServiceRequest(null, "http://service/svc", "Test");
    HttpResponse resp = mock(HttpResponse.class);
    boolean exceptionOccured = false;
    try {
        req.interpretResponse(500, resp);
    } catch (ServiceMethodException e) {
        assertEquals(500, e.getResponseCode());
        exceptionOccured = true;
    }
    assertTrue(exceptionOccured);
}
Also used : HttpResponse(org.apache.http.HttpResponse) ServiceMethodException(org.nhindirect.common.rest.exceptions.ServiceMethodException) Test(org.junit.Test)

Aggregations

HttpResponse (org.apache.http.HttpResponse)3 Test (org.junit.Test)3 ServiceMethodException (org.nhindirect.common.rest.exceptions.ServiceMethodException)3