keith-turner commented on code in PR #5981:
URL: https://github.com/apache/accumulo/pull/5981#discussion_r2547060851


##########
core/src/test/java/org/apache/accumulo/core/client/admin/compaction/CompactableFileTest.java:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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
+ *
+ *   https://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.accumulo.core.client.admin.compaction;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+import java.net.URI;
+
+import org.apache.accumulo.core.data.RowRange;
+import org.junit.jupiter.api.Test;
+
+class CompactableFileTest {
+  @Test
+  public void testEqualsHashcode() throws Exception {
+    String prefix = "hdfs://fake/accumulo/tables/1/t-0000000z/";
+    var cf1 = CompactableFile.create(new URI(prefix + "F1.rf"), 100, 10);
+    assertEquals(new URI(prefix + "F1.rf"), cf1.getUri());
+    assertEquals(100, cf1.getEstimatedSize());
+    assertEquals(10, cf1.getEstimatedEntries());
+
+    // create compactable files with one change
+    var cf2 = CompactableFile.create(new URI(prefix + "F2.rf"), 100, 10);
+    var cf3 = CompactableFile.create(new URI(prefix + "F1.rf"), 101, 10);
+    var cf4 = CompactableFile.create(new URI(prefix + "F1.rf"), 100, 11);
+
+    assertNotEquals(cf1, cf2);
+    assertNotEquals(cf1.hashCode(), cf2.hashCode());
+    assertEquals(cf1, cf3);
+    assertEquals(cf1.hashCode(), cf3.hashCode());
+    assertEquals(cf1, cf4);
+    assertEquals(cf1.hashCode(), cf3.hashCode());
+
+    var cf5 = CompactableFile.create(new URI(prefix + "F1.rf"), 100, 11);
+    assertEquals(cf1, cf5);
+    assertEquals(cf1.hashCode(), cf5.hashCode());

Review Comment:
   > I think you probably intended for the above, otherwise it's exactly the 
same as cf4
   
   
   Not sure what I was trying to do there, think I may have copy and pasted to 
start something new and got distracted.  Your suggestion seemd good though so 
did that.  In general I have been trying to comment about intent when writing 
unit test because I find its hard to look at old unit test and figure out what 
the intent was when needing to change a test.



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