reswqa commented on code in PR #22445:
URL: https://github.com/apache/flink/pull/22445#discussion_r1177297848


##########
flink-queryable-state/flink-queryable-state-client-java/src/test/java/org/apache/flink/queryablestate/client/state/ImmutableListStateTest.java:
##########
@@ -56,26 +57,23 @@ public void setUp() throws Exception {
         listState = ImmutableListState.createState(listStateDesc, serInit);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testUpdate() throws Exception {
+    @Test
+    void testUpdate() throws Exception {
         List<Long> list = getStateContents();
-        assertEquals(1L, list.size());
-
-        long element = list.get(0);
-        assertEquals(42L, element);
-
-        listState.add(54L);
+        assertThat(list).hasSize(1);
+        assertThat(list).containsExactly(42L);
+        assertThatThrownBy(() -> listState.add(54L))
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testClear() throws Exception {
+    @Test
+    void testClear() throws Exception {
         List<Long> list = getStateContents();
-        assertEquals(1L, list.size());
-
-        long element = list.get(0);
-        assertEquals(42L, element);
+        assertThat(list).hasSize(1);
 
-        listState.clear();
+        assertThat(list).containsExactly(42L);

Review Comment:
   assertThat(list).containsExactly(42L);



##########
flink-queryable-state/flink-queryable-state-client-java/src/test/java/org/apache/flink/queryablestate/client/state/ImmutableMapStateTest.java:
##########
@@ -63,130 +62,147 @@ public void setUp() throws Exception {
         mapState = ImmutableMapState.createState(mapStateDesc, initSer);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testPut() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testPut() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        mapState.put(2L, 54L);
+        assertThat(value).isEqualTo(5L);
+        assertThatThrownBy(() -> mapState.put(2L, 54L))
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testPutAll() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testPutAll() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
         Map<Long, Long> nMap = new HashMap<>();
         nMap.put(1L, 7L);
         nMap.put(2L, 7L);
-
-        mapState.putAll(nMap);
+        assertThatThrownBy(() -> mapState.putAll(nMap))
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testUpdate() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testUpdate() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        mapState.put(2L, 54L);
+        assertThat(value).isEqualTo(5L);
+        assertThatThrownBy(() -> mapState.put(2L, 54L))
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testIterator() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testIterator() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        Iterator<Map.Entry<Long, Long>> iterator = mapState.iterator();
-        while (iterator.hasNext()) {
-            iterator.remove();
-        }
+        assertThat(value).isEqualTo(5L);
+        assertThatThrownBy(
+                        () -> {
+                            Iterator<Map.Entry<Long, Long>> iterator = 
mapState.iterator();
+                            while (iterator.hasNext()) {
+                                iterator.remove();
+                            }
+                        })
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testIterable() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testIterable() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        Iterable<Map.Entry<Long, Long>> iterable = mapState.entries();
-        Iterator<Map.Entry<Long, Long>> iterator = iterable.iterator();
-        while (iterator.hasNext()) {
-            assertEquals(5L, (long) iterator.next().getValue());
-            iterator.remove();
-        }
+        assertThat(value).isEqualTo(5L);
+        assertThatThrownBy(
+                        () -> {
+                            Iterable<Map.Entry<Long, Long>> iterable = 
mapState.entries();
+                            Iterator<Map.Entry<Long, Long>> iterator = 
iterable.iterator();
+                            while (iterator.hasNext()) {
+                                assertThat((long) 
iterator.next().getValue()).isEqualTo(5L);
+                                iterator.remove();
+                            }
+                        })
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testKeys() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testKeys() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        Iterator<Long> iterator = mapState.keys().iterator();
-        while (iterator.hasNext()) {
-            iterator.remove();
-        }
+        assertThat(value).isEqualTo(5L);
+        assertThatThrownBy(
+                        () -> {
+                            Iterator<Long> iterator = 
mapState.keys().iterator();
+                            while (iterator.hasNext()) {
+                                iterator.remove();
+                            }
+                        })
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testValues() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testValues() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
-
-        Iterator<Long> iterator = mapState.values().iterator();
-        while (iterator.hasNext()) {
-            iterator.remove();
-        }
+        assertThat(value).isEqualTo(5L);
+
+        assertThatThrownBy(
+                        () -> {
+                            Iterator<Long> iterator = 
mapState.values().iterator();
+                            while (iterator.hasNext()) {
+                                iterator.remove();
+                            }
+                        })
+                .isInstanceOf(UnsupportedOperationException.class);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testClear() throws Exception {
-        assertTrue(mapState.contains(1L));
+    @Test
+    void testClear() throws Exception {
+        assertThat(mapState.contains(1L)).isTrue();
         long value = mapState.get(1L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        assertTrue(mapState.contains(2L));
+        assertThat(mapState.contains(2L)).isTrue();
         value = mapState.get(2L);
-        assertEquals(5L, value);
+        assertThat(value).isEqualTo(5L);
 
-        mapState.clear();
+        assertThatThrownBy(
+                        () -> {
+                            mapState.clear();
+                        })

Review Comment:
   ```suggestion
                   assertThatThrownBy(() -> mapState.clear())
   ```



##########
flink-queryable-state/flink-queryable-state-client-java/src/test/java/org/apache/flink/queryablestate/client/state/ImmutableListStateTest.java:
##########
@@ -56,26 +57,23 @@ public void setUp() throws Exception {
         listState = ImmutableListState.createState(listStateDesc, serInit);
     }
 
-    @Test(expected = UnsupportedOperationException.class)
-    public void testUpdate() throws Exception {
+    @Test
+    void testUpdate() throws Exception {
         List<Long> list = getStateContents();
-        assertEquals(1L, list.size());
-
-        long element = list.get(0);
-        assertEquals(42L, element);
-
-        listState.add(54L);
+        assertThat(list).hasSize(1);
+        assertThat(list).containsExactly(42L);

Review Comment:
   ```suggestion
       assertThat(list).containsExactly(42L);
   ```



-- 
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