shishkovilja commented on code in PR #12372:
URL: https://github.com/apache/ignite/pull/12372#discussion_r2402507855


##########
modules/core/src/test/java/org/apache/ignite/internal/transactions/TransactionIsolationMessageTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.ignite.internal.transactions;
+
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
+
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class TransactionIsolationMessageTest {
+    /** */
+    @Test
+    public void testTransactionIsolationCode() {
+        assertEquals(-1, new TransactionIsolationMessage(null).code());
+        assertEquals(0, new 
TransactionIsolationMessage(TransactionIsolation.READ_COMMITTED).code());
+        assertEquals(1, new 
TransactionIsolationMessage(TransactionIsolation.REPEATABLE_READ).code());
+        assertEquals(2, new 
TransactionIsolationMessage(TransactionIsolation.SERIALIZABLE).code());
+
+        for (TransactionIsolation isolation : TransactionIsolation.values())
+            assertTrue(new TransactionIsolationMessage(isolation).code() != 
-1);
+    }
+
+    /** */
+    @Test
+    public void testTransactionIsolationFromCode() {
+        TransactionIsolationMessage msg = new 
TransactionIsolationMessage(null);
+
+        msg.code((byte)-1);
+        assertNull(msg.value());
+
+        msg.code((byte)0);
+        assertSame(TransactionIsolation.READ_COMMITTED, msg.value());
+
+        msg.code((byte)1);
+        assertSame(TransactionIsolation.REPEATABLE_READ, msg.value());
+
+        msg.code((byte)2);
+        assertSame(TransactionIsolation.SERIALIZABLE, msg.value());
+
+        Throwable t = assertThrowsWithCause(() -> msg.code((byte)3), 
IllegalArgumentException.class);
+        assertEquals("Unknown transaction isolation code: 3", t.getMessage());
+    }
+
+    /** */
+    @Test
+    public void testConversion() {

Review Comment:
   ```suggestion
       public void testConversionConsistency() {
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/transactions/TransactionIsolationMessageTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.ignite.internal.transactions;
+
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
+
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class TransactionIsolationMessageTest {
+    /** */
+    @Test
+    public void testTransactionIsolationCode() {
+        assertEquals(-1, new TransactionIsolationMessage(null).code());
+        assertEquals(0, new 
TransactionIsolationMessage(TransactionIsolation.READ_COMMITTED).code());
+        assertEquals(1, new 
TransactionIsolationMessage(TransactionIsolation.REPEATABLE_READ).code());
+        assertEquals(2, new 
TransactionIsolationMessage(TransactionIsolation.SERIALIZABLE).code());
+
+        for (TransactionIsolation isolation : TransactionIsolation.values())
+            assertTrue(new TransactionIsolationMessage(isolation).code() != 
-1);
+    }
+
+    /** */
+    @Test
+    public void testTransactionIsolationFromCode() {
+        TransactionIsolationMessage msg = new 
TransactionIsolationMessage(null);
+
+        msg.code((byte)-1);
+        assertNull(msg.value());
+
+        msg.code((byte)0);
+        assertSame(TransactionIsolation.READ_COMMITTED, msg.value());
+
+        msg.code((byte)1);
+        assertSame(TransactionIsolation.REPEATABLE_READ, msg.value());
+
+        msg.code((byte)2);
+        assertSame(TransactionIsolation.SERIALIZABLE, msg.value());
+
+        Throwable t = assertThrowsWithCause(() -> msg.code((byte)3), 
IllegalArgumentException.class);
+        assertEquals("Unknown transaction isolation code: 3", t.getMessage());
+    }
+
+    /** */
+    @Test
+    public void testConversion() {
+        for (TransactionIsolation isolation : TransactionIsolation.values()) {

Review Comment:
   ```suggestion
           for (TransactionIsolation isolation : 
F.concat(TransactionIsolation.values(), (TransactionIsolation)null)) {
   ```



##########
modules/core/src/test/java/org/apache/ignite/internal/transactions/TransactionIsolationMessageTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.ignite.internal.transactions;
+
+import org.apache.ignite.transactions.TransactionIsolation;
+import org.junit.Test;
+
+import static 
org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/** */
+public class TransactionIsolationMessageTest {
+    /** */
+    @Test
+    public void testTransactionIsolationCode() {
+        assertEquals(-1, new TransactionIsolationMessage(null).code());
+        assertEquals(0, new 
TransactionIsolationMessage(TransactionIsolation.READ_COMMITTED).code());
+        assertEquals(1, new 
TransactionIsolationMessage(TransactionIsolation.REPEATABLE_READ).code());
+        assertEquals(2, new 
TransactionIsolationMessage(TransactionIsolation.SERIALIZABLE).code());
+
+        for (TransactionIsolation isolation : TransactionIsolation.values())
+            assertTrue(new TransactionIsolationMessage(isolation).code() != 
-1);
+    }
+
+    /** */
+    @Test
+    public void testTransactionIsolationFromCode() {
+        TransactionIsolationMessage msg = new 
TransactionIsolationMessage(null);
+
+        msg.code((byte)-1);
+        assertNull(msg.value());
+
+        msg.code((byte)0);
+        assertSame(TransactionIsolation.READ_COMMITTED, msg.value());
+
+        msg.code((byte)1);
+        assertSame(TransactionIsolation.REPEATABLE_READ, msg.value());
+
+        msg.code((byte)2);
+        assertSame(TransactionIsolation.SERIALIZABLE, msg.value());
+
+        Throwable t = assertThrowsWithCause(() -> msg.code((byte)3), 
IllegalArgumentException.class);
+        assertEquals("Unknown transaction isolation code: 3", t.getMessage());
+    }
+
+    /** */
+    @Test
+    public void testConversion() {
+        for (TransactionIsolation isolation : TransactionIsolation.values()) {
+            TransactionIsolationMessage msg = new 
TransactionIsolationMessage(isolation);
+
+            assertEquals(isolation, msg.value());
+
+            TransactionIsolationMessage newMsg = new 
TransactionIsolationMessage();
+            newMsg.code(msg.code());
+
+            assertEquals(msg.value(), newMsg.value());
+        }

Review Comment:
   All lines below can be removed.



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