mmiklavc commented on a change in pull request #1554: METRON-2307: Migrate to 
JUnit5
URL: https://github.com/apache/metron/pull/1554#discussion_r346926591
 
 

 ##########
 File path: 
metron-analytics/metron-statistics/src/test/java/org/apache/metron/statistics/approximation/HyperLogLogPlusFunctionsTest.java
 ##########
 @@ -18,37 +18,33 @@
 package org.apache.metron.statistics.approximation;
 
 import com.google.common.collect.ImmutableList;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
 import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class HyperLogLogPlusFunctionsTest {
 
   @Test
   public void hllp_init_creates_HyperLogLogPlus_set() {
     HyperLogLogPlus hllp = (HyperLogLogPlus) new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of());
-    Assert.assertThat(hllp.getSp(), equalTo(25));
-    Assert.assertThat(hllp.getP(), equalTo(14));
-    Assert.assertThat("instance types should match for constructor with 
default precision values", new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5)), 
instanceOf(HyperLogLogPlus.class));
-    Assert.assertThat("instance types should match for constructor with sparse 
set disabled", new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5)), 
instanceOf(HyperLogLogPlus.class));
-    Assert.assertThat("instance types should match for full constructor", new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5, 6)), 
instanceOf(HyperLogLogPlus.class));
+    assertThat(hllp.getSp(), equalTo(25));
+    assertThat(hllp.getP(), equalTo(14));
+    assertThat("instance types should match for constructor with default 
precision values", new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5)), 
instanceOf(HyperLogLogPlus.class));
+    assertThat("instance types should match for constructor with sparse set 
disabled", new HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5)), 
instanceOf(HyperLogLogPlus.class));
+    assertThat("instance types should match for full constructor", new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of(5, 6)), 
instanceOf(HyperLogLogPlus.class));
   }
 
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
   @Test
   public void hllp_init_with_incorrect_args_throws_exception() {
-    thrown.expect(IllegalArgumentException.class);
-    thrown.expectMessage("Unable to get p value from 'turkey'");
-    new HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of("turkey"));
+    Exception e = assertThrows(IllegalArgumentException.class, () -> new 
HyperLogLogPlusFunctions.HLLPInit().apply(ImmutableList.of("turkey")));
+    assertEquals("Unable to get p value from 'turkey'", e.getMessage());
 
 Review comment:
   Ah, that's how they do it re: exception message checking. Not bad. I think 
this is definitely clearer.

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

Reply via email to