diff --git a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java index 8d09c99f0f..e208add3c8 100644 --- a/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java +++ b/libraries/src/test/java/com/baeldung/hll/HLLUnitTest.java @@ -23,9 +23,9 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - hll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + hll.addRaw(hashedValue); + } ); //then @@ -44,15 +44,15 @@ public class HLLUnitTest { //when LongStream.range(0, numberOfElements).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - firstHll.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + firstHll.addRaw(hashedValue); + } ); LongStream.range(numberOfElements, numberOfElements * 2).forEach(element -> { - long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); - secondHLL.addRaw(hashedValue); - } + long hashedValue = hashFunction.newHasher().putLong(element).hash().asLong(); + secondHLL.addRaw(hashedValue); + } ); //then diff --git a/libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiTest.java b/libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiIntegrationTest.java similarity index 99% rename from libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiTest.java rename to libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiIntegrationTest.java index bdaf4d7bd9..167aef5ec6 100644 --- a/libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiTest.java +++ b/libraries/src/test/java/com/baeldung/hoverfly/HoverflyApiIntegrationTest.java @@ -31,7 +31,7 @@ import org.springframework.web.client.RestTemplate; import io.specto.hoverfly.junit.core.SimulationSource; import io.specto.hoverfly.junit.rule.HoverflyRule; -public class HoverflyApiTest { +public class HoverflyApiIntegrationTest { private static final SimulationSource source = dsl( service("http://www.baeldung.com") diff --git a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java index 23f9abf2f3..acc7718ea8 100644 --- a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java +++ b/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java @@ -1,7 +1,12 @@ package com.baeldung.pcollections; import org.junit.Test; -import org.pcollections.*; +import org.pcollections.HashPMap; +import org.pcollections.HashTreePMap; +import org.pcollections.HashTreePSet; +import org.pcollections.MapPSet; +import org.pcollections.PVector; +import org.pcollections.TreePVector; import java.util.Arrays; import java.util.HashMap; @@ -27,7 +32,7 @@ public class PCollectionsUnitTest { @Test public void givenExistingHashMap_whenFrom_thenCreateHashPMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("mkey1", "mval1"); map.put("mkey2", "mval2"); @@ -41,7 +46,7 @@ public class PCollectionsUnitTest { HashPMap pmap = HashTreePMap.empty(); HashPMap pmap0 = pmap.plus("key1", "value1"); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("key2", "val2"); map.put("key3", "val3"); @@ -57,22 +62,24 @@ public class PCollectionsUnitTest { @Test public void whenTreePVectorMethods_thenPerformOperations() { - TreePVector pVector = TreePVector.empty(); + TreePVector pVector = TreePVector.empty(); + + TreePVector pV1 = pVector.plus("e1"); + TreePVector pV2 = pV1.plusAll(Arrays.asList("e2", "e3", "e4")); - TreePVector pV1 = pVector.plus("e1"); - TreePVector pV2 = pV1.plusAll(Arrays.asList("e2", "e3", "e4")); assertEquals(1, pV1.size()); assertEquals(4, pV2.size()); - TreePVector pV3 = pV2.minus("e1"); - TreePVector pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4")); + TreePVector pV3 = pV2.minus("e1"); + TreePVector pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4")); + assertEquals(pV3.size(), 3); assertEquals(pV4.size(), 0); - TreePVector pSub = pV2.subList(0, 2); + TreePVector pSub = pV2.subList(0, 2); assertTrue(pSub.contains("e1") && pSub.contains("e2")); - TreePVector pVW = (TreePVector) pV2.with(0, "e10"); + PVector pVW = pV2.with(0, "e10"); assertEquals(pVW.get(0), "e10"); } @@ -80,7 +87,7 @@ public class PCollectionsUnitTest { public void whenMapPSetMethods_thenPerformOperations() { MapPSet pSet = HashTreePSet.empty() - .plusAll(Arrays.asList("e1","e2","e3","e4")); + .plusAll(Arrays.asList("e1", "e2", "e3", "e4")); assertEquals(pSet.size(), 4); MapPSet pSet1 = pSet.minus("e4"); diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java index cc2d3aa393..134c3c91cf 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/AtlasObserverLiveTest.java @@ -27,9 +27,6 @@ import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import static org.junit.Assert.assertThat; -/** - * @author aiet - */ public class AtlasObserverLiveTest { private final String atlasUri = "http://localhost:7101/api/v1"; diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationManualTest.java similarity index 95% rename from metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationTest.java rename to metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationManualTest.java index 3d6a73912f..2f908531f6 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationTest.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricAnnotationManualTest.java @@ -22,10 +22,7 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -/** - * @author aiet - */ -public class MetricAnnotationTest extends MetricTestBase { +public class MetricAnnotationManualTest extends MetricTestBase { @Monitor(name = "integerCounter", type = DataSourceType.COUNTER, description = "Total number of update operations.") private final AtomicInteger updateCount = new AtomicInteger(0); diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverManualTest.java similarity index 86% rename from metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverTest.java rename to metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverManualTest.java index 14d3c2646f..3bb421b3ef 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverTest.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricObserverManualTest.java @@ -13,14 +13,16 @@ import java.util.List; import static com.netflix.servo.annotations.DataSourceType.GAUGE; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -/** - * @author aiet - */ -public class MetricObserverTest extends MetricTestBase { +public class MetricObserverManualTest extends MetricTestBase { @Test public void givenMetrics_whenRegister_thenMonitored() throws InterruptedException { diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerManualTest.java similarity index 74% rename from metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerTest.java rename to metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerManualTest.java index 4a9a77efde..318170fb1f 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerTest.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricPollerManualTest.java @@ -1,20 +1,23 @@ package com.baeldung.metrics.servo; import com.netflix.servo.Metric; -import com.netflix.servo.publish.*; +import com.netflix.servo.publish.BasicMetricFilter; +import com.netflix.servo.publish.JvmMetricPoller; +import com.netflix.servo.publish.MemoryMetricObserver; +import com.netflix.servo.publish.PollRunnable; +import com.netflix.servo.publish.PollScheduler; import org.junit.Test; import java.util.List; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toList; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertThat; -/** - * @author aiet - */ -public class MetricPollerTest { +public class MetricPollerManualTest { @Test public void givenJvmPoller_whenMonitor_thenDataCollected() throws Exception { diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTestBase.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTestBase.java index 86a9d201e8..42f3c72e97 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTestBase.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTestBase.java @@ -1,14 +1,16 @@ package com.baeldung.metrics.servo; -import com.netflix.servo.publish.*; +import com.netflix.servo.publish.BasicMetricFilter; +import com.netflix.servo.publish.MemoryMetricObserver; +import com.netflix.servo.publish.MetricFilter; +import com.netflix.servo.publish.MonitorRegistryMetricPoller; +import com.netflix.servo.publish.PollRunnable; +import com.netflix.servo.publish.PollScheduler; import org.junit.After; import org.junit.Before; import static java.util.concurrent.TimeUnit.SECONDS; -/** - * @author aiet - */ abstract class MetricTestBase { MemoryMetricObserver observer; diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java index 68ba23244d..99009f8d84 100644 --- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java +++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java @@ -1,6 +1,21 @@ package com.baeldung.metrics.servo; -import com.netflix.servo.monitor.*; +import com.netflix.servo.monitor.BasicCounter; +import com.netflix.servo.monitor.BasicGauge; +import com.netflix.servo.monitor.BasicInformational; +import com.netflix.servo.monitor.BasicTimer; +import com.netflix.servo.monitor.BucketConfig; +import com.netflix.servo.monitor.BucketTimer; +import com.netflix.servo.monitor.Counter; +import com.netflix.servo.monitor.Gauge; +import com.netflix.servo.monitor.MaxGauge; +import com.netflix.servo.monitor.Monitor; +import com.netflix.servo.monitor.MonitorConfig; +import com.netflix.servo.monitor.Monitors; +import com.netflix.servo.monitor.PeakRateCounter; +import com.netflix.servo.monitor.StatsTimer; +import com.netflix.servo.monitor.StepCounter; +import com.netflix.servo.monitor.Stopwatch; import com.netflix.servo.stats.StatsConfig; import org.junit.Ignore; import org.junit.Test; @@ -9,13 +24,12 @@ import java.util.Map; import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.stream.Collectors.toMap; -import static org.hamcrest.Matchers.*; +import static org.hamcrest.Matchers.allOf; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.hasEntry; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -/** - * Unit test for simple App. - */ public class MetricTypeTest { @Test @@ -113,7 +127,7 @@ public class MetricTypeTest { BucketTimer timer = new BucketTimer(MonitorConfig .builder("test") .build(), new BucketConfig.Builder() - .withBuckets(new long[] { 2L, 5L }) + .withBuckets(new long[]{2L, 5L}) .withTimeUnit(SECONDS) .build(), SECONDS); timer.record(3); @@ -150,7 +164,7 @@ public class MetricTypeTest { .builder("test") .build(), new StatsConfig.Builder() .withComputeFrequencyMillis(2000) - .withPercentiles(new double[] { 99.0, 95.0, 90.0 }) + .withPercentiles(new double[]{99.0, 95.0, 90.0}) .withPublishMax(true) .withPublishMin(true) .withPublishCount(true)