use of com.google.protobuf.util.JsonTestProto.TestCustomJsonName in project curiostack by curioswitch.
the class MessageMarshallerTest method customJsonName.
@Test
public void customJsonName() throws Exception {
TestCustomJsonName message = TestCustomJsonName.newBuilder().setValue(12345).build();
assertMatchesUpstream(message);
}
use of com.google.protobuf.util.JsonTestProto.TestCustomJsonName in project curiostack by curioswitch.
the class MessageMarshallerTest method preservingProtoFieldNames.
@Test
public void preservingProtoFieldNames() throws Exception {
TestAllTypes message = TestAllTypes.newBuilder().setOptionalInt32(12345).build();
assertMatchesUpstream(message);
assertMatchesUpstream(message, false, true, false);
// The json_name field option is ignored when configured to use original proto field names.
TestCustomJsonName messageWithCustomJsonName = TestCustomJsonName.newBuilder().setValue(12345).build();
assertMatchesUpstream(message, false, true, false);
// Parsers accept both original proto field names and lowerCamelCase names.
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
mergeFromJson("{\"optionalInt32\": 12345}", builder);
assertEquals(12345, builder.getOptionalInt32());
builder.clear();
mergeFromJson("{\"optional_int32\": 54321}", builder);
assertEquals(54321, builder.getOptionalInt32());
}
Aggregations