From f946fc8297f2fb67062374c8c73f3130ddfd6115 Mon Sep 17 00:00:00 2001 From: jhaber Date: Sun, 31 Dec 2023 05:05:25 -0500 Subject: [PATCH] Add another test --- .../datatype/protobuf/PropertyNamingTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/java/com/hubspot/jackson/datatype/protobuf/PropertyNamingTest.java b/src/test/java/com/hubspot/jackson/datatype/protobuf/PropertyNamingTest.java index 45a3b6f..a1dcb31 100644 --- a/src/test/java/com/hubspot/jackson/datatype/protobuf/PropertyNamingTest.java +++ b/src/test/java/com/hubspot/jackson/datatype/protobuf/PropertyNamingTest.java @@ -149,6 +149,25 @@ public String nameForField( .isEqualTo(message.getStringAttribute()); } + @Test + public void testSingleNoNamingStrategy() { + PropertyNamingCamelCased message = ProtobufCreator.create( + PropertyNamingCamelCased.class + ); + + @SuppressWarnings("serial") + ObjectMapper mapper = new ObjectMapper() + .registerModule(new ProtobufModule()); + + JsonNode tree = toTree(mapper, message); + + assertThat(tree.isObject()).isTrue(); + assertThat(tree.size()).isEqualTo(1); + assertThat(tree.get("stringattribute")).isNotNull(); + assertThat(tree.get("stringattribute").textValue()) + .isEqualTo(message.getStringAttribute()); + } + @Test public void testSingleStillCamelCaseUsingNamingBase() { PropertyNamingCamelCased message = ProtobufCreator.create( @@ -208,6 +227,34 @@ public String nameForField( } } + @Test + public void testMultipleNoNamingStrategy() { + List messages = ProtobufCreator.create( + PropertyNamingCamelCased.class, + 10 + ); + + @SuppressWarnings("serial") + ObjectMapper mapper = new ObjectMapper() + .registerModule(new ProtobufModule()); + + JsonNode tree = toTree(mapper, messages); + + assertThat(tree).isInstanceOf(ArrayNode.class); + assertThat(tree.size()).isEqualTo(10); + + for (int i = 0; i < 10; i++) { + JsonNode subTree = tree.get(i); + + assertThat(subTree.isObject()).isTrue(); + assertThat(subTree.size()).isEqualTo(1); + assertThat(subTree.get("stringattribute")).isNotNull(); + assertThat(subTree.get("stringattribute").textValue()) + .isEqualTo(messages.get(i).getStringAttribute()); + } + } + + @Test public void testMultipleStillCamelCaseUsingNamingBase() { List messages = ProtobufCreator.create(