You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by dk...@apache.org on 2020/05/22 11:59:00 UTC

[avro] branch master updated: [AVRO-2639] Grab unit test from #726, Rest was already done as part of #817 Closes #726

This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/master by this push:
     new 734ea36  [AVRO-2639] Grab unit test from #726, Rest was already done as part of #817 Closes #726
734ea36 is described below

commit 734ea36dfe00fb70b506b4e987f0ad8341bcad94
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Fri May 22 07:56:50 2020 -0400

    [AVRO-2639] Grab unit test from #726, Rest was already done as part of #817
    Closes #726
---
 .../avro/compiler/specific/TestSpecificCompiler.java   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
index 5953f21..a3c8a30 100644
--- a/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
+++ b/lang/java/compiler/src/test/java/org/apache/avro/compiler/specific/TestSpecificCompiler.java
@@ -752,6 +752,23 @@ public class TestSpecificCompiler {
   }
 
   @Test
+  public void testPojoWithOptionalOnlyWhenNullableCreatedTurnedOnAndGettersReturnOptionalTurnedOff()
+      throws IOException {
+    SpecificCompiler compiler = createCompiler();
+    compiler.setOptionalGettersForNullableFieldsOnly(true);
+    compiler.compileToDestination(this.src, OUTPUT_DIR.getRoot());
+    assertTrue(this.outputFile.exists());
+    try (BufferedReader reader = new BufferedReader(new FileReader(this.outputFile))) {
+      String line;
+      while ((line = reader.readLine()) != null) {
+        line = line.trim();
+        // no optionals since gettersReturnOptionalOnlyForNullable is false
+        assertFalse(line.contains("Optional"));
+      }
+    }
+  }
+
+  @Test
   public void testAdditionalToolsAreInjectedIntoTemplate() throws Exception {
     SpecificCompiler compiler = createCompiler();
     List<Object> customTools = new ArrayList<>();
@@ -772,4 +789,5 @@ public class TestSpecificCompiler {
     }
     assertEquals(1, itWorksFound);
   }
+
 }