jihoonson commented on a change in pull request #7933: #7858 Throwing 
UnsupportedOperationException from ImmutableDruidDataSource's equals() and 
hashCode() methods
URL: https://github.com/apache/incubator-druid/pull/7933#discussion_r297338060
 
 

 ##########
 File path: 
server/src/test/java/org/apache/druid/client/ImmutableDruidDataSourceTest.java
 ##########
 @@ -26,39 +26,76 @@
 import com.google.common.collect.ImmutableSortedMap;
 import org.apache.druid.jackson.DefaultObjectMapper;
 import org.apache.druid.java.util.common.Intervals;
+import org.apache.druid.test.utils.TestUtils;
 import org.apache.druid.timeline.DataSegment;
 import org.apache.druid.timeline.DataSegment.PruneLoadSpecHolder;
-import org.junit.Assert;
 import org.junit.Test;
 
+import javax.annotation.Nonnull;
 import java.io.IOException;
 
 public class ImmutableDruidDataSourceTest
 {
   @Test
   public void testSerde() throws IOException
   {
-    final DataSegment segment = new DataSegment(
-        "test",
-        Intervals.of("2017/2018"),
-        "version",
-        null,
-        ImmutableList.of("dim1", "dim2"),
-        ImmutableList.of("met1", "met2"),
-        null,
-        1,
-        100L,
-        PruneLoadSpecHolder.DEFAULT
-    );
-    final ImmutableDruidDataSource dataSource = new ImmutableDruidDataSource(
-        "test",
-        ImmutableMap.of("prop1", "val1", "prop2", "val2"),
-        ImmutableSortedMap.of(segment.getId(), segment)
-    );
+    final DataSegment segment = getTestSegment();
+    final ImmutableDruidDataSource dataSource = 
getImmutableDruidDataSource(segment);
 
     final ObjectMapper objectMapper = new DefaultObjectMapper()
         .setInjectableValues(new Std().addValue(PruneLoadSpecHolder.class, 
PruneLoadSpecHolder.DEFAULT));
     final String json = objectMapper.writeValueAsString(dataSource);
-    Assert.assertEquals(dataSource, objectMapper.readValue(json, 
ImmutableDruidDataSource.class));
+
+    TestUtils.assertEqualsImmutableDruidDataSource(dataSource, 
objectMapper.readValue(json, ImmutableDruidDataSource.class));
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
+  public void testEqualsMethodThrowsUnsupportedOperationException()
+  {
+    final DataSegment segment1 = getTestSegment();
+
+    final ImmutableDruidDataSource dataSource1 = 
getImmutableDruidDataSource(segment1);
+
+    final DataSegment segment2 = getTestSegment();
+
+    final ImmutableDruidDataSource dataSource2 = 
getImmutableDruidDataSource(segment2);
+
+    dataSource1.equals(dataSource2);
+  }
+
+  @Nonnull
+  private ImmutableDruidDataSource getImmutableDruidDataSource(DataSegment 
segment1)
+  {
+    return new ImmutableDruidDataSource(
+      "test",
+      ImmutableMap.of("prop1", "val1", "prop2", "val2"),
+      ImmutableSortedMap.of(segment1.getId(), segment1)
+    );
+  }
+
+  @Nonnull
+  private DataSegment getTestSegment()
+  {
+    return new DataSegment(
+      "test",
+      Intervals.of("2017/2018"),
+      "version",
+      null,
+      ImmutableList.of("dim1", "dim2"),
+      ImmutableList.of("met1", "met2"),
+      null,
+      1,
+      100L,
+      PruneLoadSpecHolder.DEFAULT
+    );
+  }
+
+  @Test(expected = UnsupportedOperationException.class)
 
 Review comment:
   Same here. Use `ExpectedException` instead.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to