Build opt 9 08 2017 (#2397)

* pCollections

* Reformat

* Refactor metrics

* Refactor hoverfly
This commit is contained in:
Grzegorz Piwowarek 2017-08-09 15:32:08 +02:00 committed by GitHub
parent 69f3e1175a
commit b5478f7e9a
9 changed files with 72 additions and 50 deletions

View File

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

View File

@ -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")

View File

@ -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<String, String> map = new HashMap<>();
map.put("mkey1", "mval1");
map.put("mkey2", "mval2");
@ -41,7 +46,7 @@ public class PCollectionsUnitTest {
HashPMap<String, String> pmap = HashTreePMap.empty();
HashPMap<String, String> pmap0 = pmap.plus("key1", "value1");
Map map = new HashMap();
Map<String, String> 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<String> pVector = TreePVector.empty();
TreePVector<String> pV1 = pVector.plus("e1");
TreePVector<String> 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<String> pV3 = pV2.minus("e1");
TreePVector<String> pV4 = pV3.minusAll(Arrays.asList("e2", "e3", "e4"));
assertEquals(pV3.size(), 3);
assertEquals(pV4.size(), 0);
TreePVector pSub = pV2.subList(0, 2);
TreePVector<String> pSub = pV2.subList(0, 2);
assertTrue(pSub.contains("e1") && pSub.contains("e2"));
TreePVector pVW = (TreePVector) pV2.with(0, "e10");
PVector<String> 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");

View File

@ -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";

View File

@ -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);

View File

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

View File

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

View File

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

View File

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