diff --git a/gax-httpjson/src/test/java/com/google/api/gax/httpjson/ApiMessageHttpRequestTest.java b/gax-httpjson/src/test/java/com/google/api/gax/httpjson/ApiMessageHttpRequestTest.java index 05e99fbe4..c14573b1a 100644 --- a/gax-httpjson/src/test/java/com/google/api/gax/httpjson/ApiMessageHttpRequestTest.java +++ b/gax-httpjson/src/test/java/com/google/api/gax/httpjson/ApiMessageHttpRequestTest.java @@ -81,6 +81,21 @@ public void testFieldMask() throws IOException { .isEqualTo("{\"name\":\"tree_frog\",\"limbs\":[\"legs\"],\"poisonous\":null}"); } + @Test + public void testPartialFieldMask() throws IOException { + List fieldMask = Lists.newArrayList("name", "poisonous"); + FrogMessage frogMessage = new FrogMessage("tree_frog", 4, Lists.newArrayList("legs"), null); + + InsertFrogRequest insertFrogRequest = + new InsertFrogRequest("name/tree_frog", "request57", frogMessage, fieldMask); + + OutputStream outputStream = insertFrog(insertFrogRequest); + + // JSON content string must contain all and ONLY the fields in fieldMask, even if the value is null. + Truth.assertThat(outputStream.toString()) + .isEqualTo("{\"name\":\"tree_frog\",\"poisonous\":null}"); + } + @Test public void testNullFieldMask() throws IOException { List nullFieldMask = null;