Search in sources :

Example 1 with User

use of org.apache.servicecomb.foundation.protobuf.internal.model.User 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 User

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

the class TestBytesSchema method type_invalid.

@Test
public void type_invalid() throws Throwable {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage(Matchers.is("not support serialize from org.apache.servicecomb.foundation.protobuf.internal.model.User to proto bytes, field=org.apache.servicecomb.foundation.protobuf.internal.model.Root:bytes"));
    scbMap = new HashMap<>();
    scbMap.put("bytes", new User());
    rootSerializer.serialize(scbMap);
}
Also used : User(org.apache.servicecomb.foundation.protobuf.internal.model.User) Test(org.junit.Test)

Example 3 with User

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

the class TestEnumSchema method type_invalid.

@Test
public void type_invalid() throws Throwable {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage(Matchers.is("not support serialize from org.apache.servicecomb.foundation.protobuf.internal.model.User to proto Color, field=org.apache.servicecomb.foundation.protobuf.internal.model.Root:color"));
    scbMap = new HashMap<>();
    scbMap.put("color", new User());
    rootSerializer.serialize(scbMap);
}
Also used : User(org.apache.servicecomb.foundation.protobuf.internal.model.User) Test(org.junit.Test)

Example 4 with User

use of org.apache.servicecomb.foundation.protobuf.internal.model.User 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)

Example 5 with User

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

the class TestEnumSchema method type_invalid.

@Test
public void type_invalid() throws Throwable {
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage(Matchers.is("not support serialize from org.apache.servicecomb.foundation.protobuf.internal.model.User to proto Color, field=org.apache.servicecomb.foundation.protobuf.internal.model.Root:color"));
    scbMap = new HashMap<>();
    scbMap.put("color", new User());
    rootSerializer.serialize(scbMap);
}
Also used : User(org.apache.servicecomb.foundation.protobuf.internal.model.User) Test(org.junit.Test)

Aggregations

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