@Test void noRangeAvailable() { BillOfMaterials bom = BillOfMaterials.create("com.example", "bom"); bom.getMappings().add(Mapping.create("[1.2.0.RELEASE,1.3.0.M1)", "1.1.0")); bom.getMappings().add(Mapping.create("[1.3.0.M1, 1.4.0.M1)", "1.2.0")); bom.validate(); assertThatIllegalStateException() .isThrownBy(() -> bom.resolve(Version.parse("1.4.1.RELEASE"))) .withMessageContaining("1.4.1.RELEASE"); }
@Test public void queuePollError() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); MicrometerMonoMetricsFuseableSubscriber<Integer> fuseableSubscriber = new MicrometerMonoMetricsFuseableSubscriber<>(testSubscriber, registry, clock, "foo", Collections.emptyList()); FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.setCompleteWithError(true); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); clock.add(Duration.ofMillis(123)); assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll) .withMessage("AssertQueueSubscriber poll error"); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tag(TAG_STATUS, TAGVALUE_ON_ERROR) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323); }
@Test public void queuePollError() { //prepare registry with mock clock MockClock clock = new MockClock(); removeRegistry(); registry = new SimpleMeterRegistry(SimpleConfig.DEFAULT, clock); Metrics.globalRegistry.add(registry); AssertSubscriber<Integer> testSubscriber = AssertSubscriber.create(); MicrometerFluxMetricsFuseableSubscriber<Integer> fuseableSubscriber = new MicrometerFluxMetricsFuseableSubscriber<>(testSubscriber, registry, clock, "foo", Collections.emptyList()); FluxPeekFuseableTest.AssertQueueSubscription<Integer> testQueue = new FluxPeekFuseableTest.AssertQueueSubscription<>(); testQueue.setCompleteWithError(true); testQueue.offer(1); fuseableSubscriber.onSubscribe(testQueue); fuseableSubscriber.requestFusion(Fuseable.SYNC); clock.add(Duration.ofMillis(200)); Integer val1 = fuseableSubscriber.poll(); assertThat(val1).isEqualTo(1); clock.add(Duration.ofMillis(123)); assertThatIllegalStateException().isThrownBy(fuseableSubscriber::poll) .withMessage("AssertQueueSubscriber poll error"); //test meters Timer terminationTimer = registry.find(METER_FLOW_DURATION) .tag(TAG_STATUS, TAGVALUE_ON_ERROR) .timer(); assertThat(terminationTimer).isNotNull(); assertThat(terminationTimer.max(TimeUnit.MILLISECONDS)).as("terminate max delay").isEqualTo(323); }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"IntSerializer\",\"value\": []}")); }
@Test void fromJsonStringShouldThrowOnMissingSerializerField() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"value\": \"value\"}")); }
@Test void fromJsonStringShouldThrowOnMissingValueField() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MapSerializer\"}")); }
@Test void fromJsonStringShouldThrowOnFloatJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"LongSerializer\",\"value\": 42.0}")); } }
@Test void fromJsonStringShouldThrowOnIntNode() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"DoubleSerializer\",\"value\": 1}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"CollectionSerializer\",\"value\": {}}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"StringSerializer\",\"value\": []}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"LongSerializer\",\"value\": []}")); }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"FloatSerializer\",\"value\": []}")); }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"OptionalSerializer\",\"value\": []}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"BooleanSerializer\",\"value\": []}")); } }
@Test void fromJsonStringShouldThrowOnFloatJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"IntSerializer\",\"value\": 42.0}")); }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"DoubleSerializer\",\"value\": []}")); }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"UrlSerializer\",\"value\": {}}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MessageIdDtoSerializer\",\"value\": {}}")); } }
@Test void fromJsonStringShouldThrowOnMalformedFormattedJson() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"MapSerializer\",\"value\": []}")); } }
@Test void fromJsonStringShouldThrowOnIntNode() { assertThatIllegalStateException() .isThrownBy(() -> AttributeValue.fromJsonString("{\"serializer\":\"FloatSerializer\",\"value\": 1}")); } }