Search in sources :

Example 1 with TestOneof

use of com.google.protobuf.util.JsonTestProto.TestOneof in project curiostack by curioswitch.

the class MessageMarshallerTest method includingDefaultValueFields.

@Test
public void includingDefaultValueFields() throws Exception {
    TestAllTypes message = TestAllTypes.getDefaultInstance();
    assertMatchesUpstream(message);
    assertMatchesUpstream(message, true, false, false);
    TestMap mapMessage = TestMap.getDefaultInstance();
    assertMatchesUpstream(mapMessage);
    assertMatchesUpstream(mapMessage, true, false, false);
    TestOneof oneofMessage = TestOneof.getDefaultInstance();
    assertMatchesUpstream(oneofMessage);
    assertMatchesUpstream(oneofMessage, true, false, false);
    oneofMessage = TestOneof.newBuilder().setOneofInt32(42).build();
    assertMatchesUpstream(oneofMessage);
    assertMatchesUpstream(oneofMessage, true, false, false);
    oneofMessage = TestOneof.newBuilder().setOneofNullValue(NullValue.NULL_VALUE).build();
    assertMatchesUpstream(oneofMessage);
    assertMatchesUpstream(oneofMessage, true, false, false);
}
Also used : TestMap(com.google.protobuf.util.JsonTestProto.TestMap) TestAllTypes(com.google.protobuf.util.JsonTestProto.TestAllTypes) TestOneof(com.google.protobuf.util.JsonTestProto.TestOneof) Test(org.junit.Test)

Example 2 with TestOneof

use of com.google.protobuf.util.JsonTestProto.TestOneof in project curiostack by curioswitch.

the class MessageMarshallerTest method nullInOneOf.

@Test
public void nullInOneOf() throws Exception {
    TestOneof.Builder builder = TestOneof.newBuilder();
    mergeFromJson("{\n" + "  \"oneofNullValue\": null \n" + "}", builder);
    TestOneof message = builder.build();
    assertEquals(TestOneof.OneofFieldCase.ONEOF_NULL_VALUE, message.getOneofFieldCase());
    assertEquals(NullValue.NULL_VALUE, message.getOneofNullValue());
}
Also used : TestOneof(com.google.protobuf.util.JsonTestProto.TestOneof) Test(org.junit.Test)

Aggregations

TestOneof (com.google.protobuf.util.JsonTestProto.TestOneof)2 Test (org.junit.Test)2 TestAllTypes (com.google.protobuf.util.JsonTestProto.TestAllTypes)1 TestMap (com.google.protobuf.util.JsonTestProto.TestMap)1