lukecwik commented on code in PR #24093:
URL: https://github.com/apache/beam/pull/24093#discussion_r1025736259


##########
sdks/java/core/src/test/java/org/apache/beam/sdk/coders/ZstdCoderTest.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.coders;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.beam.sdk.testing.CoderProperties;
+import org.apache.beam.sdk.transforms.windowing.GlobalWindow;
+import org.apache.beam.sdk.values.KV;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test case for {@link ZstdCoder}. */
+@RunWith(JUnit4.class)
+public class ZstdCoderTest {
+  private static final ZstdCoder<String> TEST_CODER = 
ZstdCoder.of(StringUtf8Coder.of());
+
+  private static final List<String> TEST_VALUES =
+      Arrays.asList(
+          "",
+          "a",
+          "aaabbbccc",
+          "Hello world!",
+          "I am Groot. I am Groot. I am Groot.",
+          "{\"foo\":32417897,\"bar\":true}",
+          "<html><head></head><body></body></html>");
+
+  @Test
+  public void testDecodeEncodeEquals() throws Exception {
+    for (String value : TEST_VALUES) {
+      CoderProperties.coderDecodeEncodeEqual(TEST_CODER, value);
+    }
+  }
+
+  @Test
+  public void testEncodingNotBuffered() throws Exception {
+    // This test ensures that the coder does not buffer any data from the 
inner stream.
+    // This is not of much importance today, since the coder relies on direct 
compression and uses
+    // ByteArrayCoder to encode the resulting byte[], but this may change if 
the coder switches to
+    // stream based compression in which case the stream must not buffer input 
from the inner
+    // stream.
+    for (String value : TEST_VALUES) {
+      CoderProperties.coderDecodeEncodeEqual(
+          KvCoder.of(TEST_CODER, StringUtf8Coder.of()), KV.of(value, value));
+    }
+  }
+

Review Comment:
   Can you add a test for the structuralValue / consistentWithEquals?
   
   Typically a variant using StringUtf8Coder and another variant using 
ByteArrayCoder covers the two different cases.
   
   If the tests are green I can merge this as is and you could follow up with 
another PR.



##########
sdks/java/core/src/test/java/org/apache/beam/sdk/coders/ZstdCoderTest.java:
##########
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.beam.sdk.coders;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.beam.sdk.testing.CoderProperties;
+import org.apache.beam.sdk.transforms.windowing.GlobalWindow;
+import org.apache.beam.sdk.values.KV;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Test case for {@link ZstdCoder}. */
+@RunWith(JUnit4.class)
+public class ZstdCoderTest {
+  private static final ZstdCoder<String> TEST_CODER = 
ZstdCoder.of(StringUtf8Coder.of());
+
+  private static final List<String> TEST_VALUES =
+      Arrays.asList(
+          "",
+          "a",
+          "aaabbbccc",
+          "Hello world!",
+          "I am Groot. I am Groot. I am Groot.",

Review Comment:
   Nice



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to