use of org.apache.servicecomb.swagger.invocation.Response in project incubator-servicecomb-java-chassis by apache.
the class TestDefaultProducerResponseMapper method mapResponse.
@Test
public void mapResponse() {
Response result = mapper.mapResponse(Status.OK, 1);
Assert.assertSame(Status.OK, result.getStatus());
Assert.assertEquals("1", result.getResult());
}
use of org.apache.servicecomb.swagger.invocation.Response in project incubator-servicecomb-java-chassis by apache.
the class TestDefaultProducerResponseMapperFactory method createResponseMapper.
@Test
public void createResponseMapper() {
ProducerResponseMapper mapper = factory.createResponseMapper(null, String.class, Integer.class);
Response result = mapper.mapResponse(Status.OK, 1);
Assert.assertSame(Status.OK, result.getStatus());
Assert.assertEquals("1", result.getResult());
}
use of org.apache.servicecomb.swagger.invocation.Response in project incubator-servicecomb-java-chassis by apache.
the class TestJaxrsConsumerResponseMapper method mapResponse_withHeaders.
@SuppressWarnings("unchecked")
@Test
public void mapResponse_withHeaders() {
Response response = Response.create(Status.OK, "ret");
response.getHeaders().addHeader("h", "v");
mapper.mapResponse(response);
Assert.assertEquals(Status.OK.getStatusCode(), status);
Assert.assertEquals("ret", entity);
Assert.assertEquals(1, headers.size());
Assert.assertThat((List<Object>) headers.get("h"), Matchers.contains("v"));
}
use of org.apache.servicecomb.swagger.invocation.Response in project incubator-servicecomb-java-chassis by apache.
the class TestJaxrsConsumerResponseMapper method mapResponse_withoutHeaders.
@Test
public void mapResponse_withoutHeaders() {
Response response = Response.create(Status.OK, "ret");
mapper.mapResponse(response);
Assert.assertEquals(Status.OK.getStatusCode(), status);
Assert.assertEquals("ret", entity);
Assert.assertEquals(0, headers.size());
}
use of org.apache.servicecomb.swagger.invocation.Response in project incubator-servicecomb-java-chassis by apache.
the class TestJaxrsProducerResponseMapper method mapResponse_withoutHeaders.
@Test
public void mapResponse_withoutHeaders() {
new Expectations() {
{
jaxrsResponse.getStatusInfo();
result = Status.OK;
jaxrsResponse.getEntity();
result = "result";
}
};
Response response = mapper.mapResponse(null, jaxrsResponse);
Assert.assertEquals(Status.OK, response.getStatus());
Assert.assertEquals("result", response.getResult());
Assert.assertNull(response.getHeaders().getHeaderMap());
}
Aggregations