sashapolo commented on code in PR #1223:
URL: https://github.com/apache/ignite-3/pull/1223#discussion_r998071278


##########
modules/metastorage-common/src/test/java/org/apache/ignite/internal/metastorage/common/OperationTypeTest.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.metastorage.common;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests that persisted enum ordinals have not been accidentally changed by a 
developer.
+ */
+class OperationTypeTest {
+    @Test
+    void testOrdinal() {
+        assertEquals(0, OperationType.NO_OP.ordinal());
+
+        assertEquals(1, OperationType.PUT.ordinal());
+
+        assertEquals(2, OperationType.REMOVE.ordinal());
+    }
+}

Review Comment:
   Same here



##########
modules/metastorage-client/src/main/java/org/apache/ignite/internal/metastorage/client/CursorImpl.java:
##########
@@ -78,7 +83,7 @@
     public void close() {
         try {
             initOp.thenCompose(
-                    cursorId -> metaStorageRaftGrpSvc.run(new 
CursorCloseCommand(cursorId))).get();
+                    cursorId -> 
metaStorageRaftGrpSvc.run(commandsFactory.cursorCloseCommand().cursorId(cursorId).build())).get();

Review Comment:
   I would prefer if you would extract commands creation into local variables



##########
modules/metastorage-common/src/test/java/org/apache/ignite/internal/metastorage/common/ConditionTypeTest.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.metastorage.common;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests that persisted enum ordinals have not been accidentally changed by a 
developer.
+ */
+class ConditionTypeTest {
+    @Test
+    void testOrdinal() {
+        assertEquals(0, ConditionType.REV_EQUAL.ordinal());
+
+        assertEquals(1, ConditionType.REV_NOT_EQUAL.ordinal());
+
+        assertEquals(2, ConditionType.REV_GREATER.ordinal());
+
+        assertEquals(3, ConditionType.REV_LESS.ordinal());
+
+        assertEquals(4, ConditionType.REV_LESS_OR_EQUAL.ordinal());
+
+        assertEquals(5, ConditionType.REV_GREATER_OR_EQUAL.ordinal());
+
+        assertEquals(6, ConditionType.VAL_EQUAL.ordinal());
+
+        assertEquals(7, ConditionType.VAL_NOT_EQUAL.ordinal());
+
+        assertEquals(8, ConditionType.VAL_GREATER.ordinal());
+
+        assertEquals(9, ConditionType.VAL_LESS.ordinal());
+
+        assertEquals(10, ConditionType.VAL_LESS_OR_EQUAL.ordinal());
+
+        assertEquals(11, ConditionType.VAL_GREATER_OR_EQUAL.ordinal());
+
+        assertEquals(12, ConditionType.KEY_EXISTS.ordinal());
+
+        assertEquals(13, ConditionType.KEY_NOT_EXISTS.ordinal());
+
+        assertEquals(14, ConditionType.TOMBSTONE.ordinal());
+    }
+}

Review Comment:
   Missing line break, please check your IDE settings



##########
modules/metastorage-client/src/main/java/org/apache/ignite/internal/metastorage/client/MetaStorageServiceImpl.java:
##########
@@ -111,77 +106,81 @@ public MetaStorageServiceImpl(RaftGroupService 
metaStorageRaftGrpSvc, String loc
     /** {@inheritDoc} */
     @Override
     public @NotNull CompletableFuture<Entry> get(@NotNull ByteArray key) {
-        return metaStorageRaftGrpSvc.run(new 
GetCommand(key)).thenApply(MetaStorageServiceImpl::singleEntryResult);
+        return 
metaStorageRaftGrpSvc.run(commandsFactory.getCommand().key(key.bytes()).build())

Review Comment:
   Same here



##########
modules/metastorage-common/src/test/java/org/apache/ignite/internal/metastorage/common/command/CompoundConditionTypeTest.java:
##########
@@ -17,28 +17,18 @@
 
 package org.apache.ignite.internal.metastorage.common.command;
 
-import java.io.Serializable;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
-/** Defines error response. */
-public class ErrorResponse implements Serializable {
-    /** Error code. */
-    private final int errCode;
+import org.junit.jupiter.api.Test;
 
-    /**
-     * Constructs error response.
-     *
-     * @param errCode Error code
-     */
-    public ErrorResponse(int errCode) {
-        this.errCode = errCode;
-    }
+/**
+ * Tests that persisted enum ordinals have not been accidentally changed by a 
developer.
+ */
+class CompoundConditionTypeTest {
+    @Test
+    void testOrdinal() {
+        assertEquals(0, CompoundConditionType.AND.ordinal());
 
-    /**
-     * Returns error code.
-     *
-     * @return Error code.
-     */
-    public int errorCode() {
-        return errCode;
+        assertEquals(1, CompoundConditionType.OR.ordinal());
     }
-}
+}

Review Comment:
   And here



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