ferenc-csaky commented on code in PR #8:
URL: 
https://github.com/apache/flink-connector-kudu/pull/8#discussion_r1980100133


##########
flink-connector-kudu/src/test/java/org/apache/flink/connector/kudu/source/enumerator/KuduSourceEnumeratorStateSerializerTest.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.flink.connector.kudu.source.enumerator;
+
+import org.apache.flink.connector.kudu.source.split.KuduSourceSplit;
+
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+/** Tests for {@link KuduSourceEnumeratorStateSerializer}. */
+public class KuduSourceEnumeratorStateSerializerTest {
+    private final KuduSourceEnumeratorStateSerializer serializer =
+            new KuduSourceEnumeratorStateSerializer();
+
+    @Test
+    public void testSerializeDeserialize() throws IOException {
+        byte[] token1 = {1, 2, 3};
+        byte[] token2 = {4, 5, 6};
+        byte[] token3 = {7, 8, 9};
+        byte[] token4 = {10, 11, 12};
+
+        List<KuduSourceSplit> unassigned =
+                Arrays.asList(new KuduSourceSplit(token1), new 
KuduSourceSplit(token2));
+        List<KuduSourceSplit> pending =
+                Arrays.asList(new KuduSourceSplit(token3), new 
KuduSourceSplit(token4));
+        KuduSourceEnumeratorState state =
+                new KuduSourceEnumeratorState(12345L, unassigned, pending);
+
+        byte[] serialized = serializer.serialize(state);
+        KuduSourceEnumeratorState deserialized =
+                serializer.deserialize(serializer.getVersion(), serialized);
+
+        
assertThat(state.getLastEndTimestamp()).isEqualTo(deserialized.getLastEndTimestamp());
+        
assertThat(state.getUnassigned().size()).isEqualTo(deserialized.getUnassigned().size());
+        
assertThat(state.getPending().size()).isEqualTo(deserialized.getPending().size());

Review Comment:
   Correct me if I'm wrong, but it seems to me that `deserialized` will be the 
actual test result and `state` contains the expected values. If so, these 
checks should be inverted, in AssertJ `assertThat(...)` should always contain 
the actual value, not the expected. Reagrdless of this, the size comparison can 
be simplified like:
   ```java
   
assertThat(deserialized.getLastEndTimestamp()).isEqualTo(state.getLastEndTimestamp());
   
assertThat(deserialized.getUnassigned()).hasSameSizeAs(state.getUnassigned());
   assertThat(deserialized.getPending()).hasSameSizeAs(state.getPending());
   ```



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to