use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class TestConsumerResponseMapper method test.
@Test
public void test() {
ConsumerResponseMapperFactory factory = new ConsumerResponseMapperFactory();
ConsumerResponseMapper m1 = new ConsumerResponseCseSame();
ConsumerResponseMapper m2 = new ConsumerResponseSame();
factory.setMapperList(Arrays.asList(m1, m2));
Assert.assertEquals(m1, factory.createResponseMapper(Response.class));
Assert.assertEquals(m2, factory.createResponseMapper(String.class));
Response r = Response.ok(1);
Response r1 = (Response) m1.mapResponse(r);
Assert.assertEquals(r, r1);
Object result = m2.mapResponse(r);
Assert.assertEquals(1, (int) result);
}
use of io.servicecomb.core.Response in project java-chassis by ServiceComb.
the class TestProducerResponseMapper method test.
@Test
public void test() {
ProducerResponseMapperFactory factory = new ProducerResponseMapperFactory();
ProducerResponseMapper m1 = new ProducerResponseCseSame();
ProducerResponseMapper m2 = new ProducerResponseSame();
factory.setMapperList(Arrays.asList(m1, m2));
Assert.assertEquals(m1, factory.createResponseMapper(Response.class));
Assert.assertEquals(m2, factory.createResponseMapper(String.class));
Response r = Response.ok(1);
Response r1 = m1.mapResponse(null, r);
Assert.assertEquals(r, r1);
r1 = m2.mapResponse(Status.OK, 1);
Assert.assertEquals(1, (int) r1.getResult());
}
Aggregations