Search in sources :

Example 36 with Response

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);
}
Also used : Response(io.servicecomb.core.Response) Test(org.junit.Test)

Example 37 with Response

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());
}
Also used : Response(io.servicecomb.core.Response) Test(org.junit.Test)

Aggregations

Response (io.servicecomb.core.Response)37 Test (org.junit.Test)21 Invocation (io.servicecomb.core.Invocation)20 OperationMeta (io.servicecomb.core.definition.OperationMeta)11 AsyncResponse (io.servicecomb.core.AsyncResponse)8 OperationProtobuf (io.servicecomb.codec.protobuf.definition.OperationProtobuf)7 WrapSchema (io.servicecomb.codec.protobuf.utils.WrapSchema)7 HystrixCommandProperties (com.netflix.hystrix.HystrixCommandProperties)6 HttpServerResponse (io.vertx.core.http.HttpServerResponse)5 InvocationException (io.servicecomb.core.exception.InvocationException)4 MockUp (mockit.MockUp)4 ProduceProcessor (io.servicecomb.common.rest.codec.produce.ProduceProcessor)3 SyncResponseExecutor (io.servicecomb.core.provider.consumer.SyncResponseExecutor)3 User (io.servicecomb.demo.server.User)3 HttpClientResponse (io.vertx.core.http.HttpClientResponse)3 List (java.util.List)3 ExecutionListener (com.netflix.loadbalancer.reactive.ExecutionListener)2 CommonExceptionData (io.servicecomb.core.exception.CommonExceptionData)2 ResponseHeaders (io.servicecomb.swagger.extend.annotations.ResponseHeaders)2 ApiResponse (io.swagger.annotations.ApiResponse)2