Search in sources :

Example 1 with TestMap

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

the class MessageMarshallerTest method parserAcceptsNonQuotedObjectKey.

@Test
public void parserAcceptsNonQuotedObjectKey() throws Exception {
    TestMap.Builder builder = TestMap.newBuilder();
    mergeFromJson("{\n" + "  int32ToInt32Map: {1: 2},\n" + "  stringToInt32Map: {hello: 3}\n" + "}", builder);
    TestMap message = builder.build();
    assertEquals(2, message.getInt32ToInt32Map().get(1).intValue());
    assertEquals(3, message.getStringToInt32Map().get("hello").intValue());
}
Also used : TestMap(com.google.protobuf.util.JsonTestProto.TestMap) Test(org.junit.Test)

Example 2 with TestMap

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

the class MessageMarshallerTest method mapFields.

@Test
public void mapFields() throws Exception {
    assertMatchesUpstream(JsonTestUtil.testMapAllTypes());
    TestMap message = TestMap.newBuilder().putInt32ToInt32Map(1, 2).putInt32ToInt32Map(3, 4).build();
    assertMatchesUpstream(message);
}
Also used : TestMap(com.google.protobuf.util.JsonTestProto.TestMap) Test(org.junit.Test)

Example 3 with TestMap

use of com.google.protobuf.util.JsonTestProto.TestMap 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)

Aggregations

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