Search in sources :

Example 1 with CustomGeneric

use of org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric in project java-chassis by ServiceComb.

the class TestMessageSchema method generic.

@Test
public void generic() throws Throwable {
    JavaType javaType = TypeFactory.defaultInstance().constructParametricType(CustomGeneric.class, User.class);
    RootDeserializer<CustomGeneric<User>> genericDeserializer = protoMapper.createRootDeserializer("Root", javaType);
    builder.setUser(ProtobufRoot.User.newBuilder().setName("name1").build());
    check(genericDeserializer, mapRootDeserializer, rootSerializer, false);
    @SuppressWarnings("unchecked") CustomGeneric<User> generic = (CustomGeneric<User>) scbRoot;
    Assert.assertThat(generic.user, Matchers.instanceOf(User.class));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) User(org.apache.servicecomb.foundation.protobuf.internal.model.User) CustomGeneric(org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric) Test(org.junit.Test)

Example 2 with CustomGeneric

use of org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric in project incubator-servicecomb-java-chassis by apache.

the class TestMessageSchema method generic.

@Test
public void generic() throws Throwable {
    JavaType javaType = TypeFactory.defaultInstance().constructParametricType(CustomGeneric.class, User.class);
    RootDeserializer<CustomGeneric<User>> genericDeserializer = protoMapper.createRootDeserializer("Root", javaType);
    builder.setUser(ProtobufRoot.User.newBuilder().setName("name1").build());
    check(genericDeserializer, mapRootDeserializer, rootSerializer, false);
    @SuppressWarnings("unchecked") CustomGeneric<User> generic = (CustomGeneric<User>) scbRoot;
    Assert.assertThat(generic.user, Matchers.instanceOf(User.class));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) User(org.apache.servicecomb.foundation.protobuf.internal.model.User) CustomGeneric(org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric) Test(org.junit.Test)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)2 CustomGeneric (org.apache.servicecomb.foundation.protobuf.internal.model.CustomGeneric)2 User (org.apache.servicecomb.foundation.protobuf.internal.model.User)2 Test (org.junit.Test)2