@Test public void install_provides_new_Configuration_when_getBootConfiguration_is_called_and_there_is_none_in_container() { CoreExtension coreExtension1 = newCoreExtension(); CoreExtension coreExtension2 = newCoreExtension(); when(coreExtensionRepository.loadedCoreExtensions()).thenReturn(Stream.of(coreExtension1, coreExtension2)); ComponentContainer container = new ComponentContainer(); underTest.install(container, noExtensionFilter(), noAdditionalSideFilter()); verify(coreExtension1).load(contextCaptor.capture()); verify(coreExtension2).load(contextCaptor.capture()); // verify each core extension gets its own configuration assertThat(contextCaptor.getAllValues()) .hasSameElementsAs(ImmutableSet.copyOf(contextCaptor.getAllValues())); }
@Test public void testCloneIfContainsTestsWithNamesMatchingAny() { XmlSuite suite = createDummySuiteWithTestNamesAs("test1", "test2"); TestNamesMatcher testNamesMatcher = new TestNamesMatcher(suite, Collections.singletonList("test2")); List<XmlTest> xmlTests = testNamesMatcher.getMatchedTests(); assertThat(suite.getTests()).hasSameElementsAs(xmlTests); }
public void testSomethingByIterator() { final SomethingByIterator s = handle.attach(SomethingByIterator.class); List<Something> results = s.get(Arrays.asList( new SomethingKey(1, "1"), new SomethingKey(2, "2")) .iterator()); assertThat(results).hasSameElementsAs(expectedSomethings); }
public void testSomethingByIterator() { final SomethingByIterator s = handle.attach(SomethingByIterator.class); List<Something> results = s.get(Arrays.asList( new SomethingKey(1, "1"), new SomethingKey(2, "2")) .iterator()); assertThat(results).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByIterableHandleDefaultWithIterable() { final SomethingByIterableHandleDefault s = handle.attach(SomethingByIterableHandleDefault.class); final List<Something> out = s.get(new Iterable<Integer>() { @Override public Iterator<Integer> iterator() { return Arrays.asList(1, 2).iterator(); } }); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByVarargsHandleDefaultWithVarargs() { final SomethingByVarargsHandleDefault s = handle.attach(SomethingByVarargsHandleDefault.class); final List<Something> out = s.get(1, 2); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByVarargsHandleDefaultWithVarargs() { final SomethingByVarargsHandleDefault s = handle.attach(SomethingByVarargsHandleDefault.class); final List<Something> out = s.get(1, 2); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByArrayHandleVoidWithArray() { final SomethingByArrayHandleVoid s = handle.attach(SomethingByArrayHandleVoid.class); final List<Something> out = s.get(new int[]{1, 2}); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingWithExplicitAttributeName() { final SomethingWithExplicitAttributeName s = handle.attach(SomethingWithExplicitAttributeName.class); final List<Something> out = s.get(1, 2); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByArrayHandleVoidWithArray() { final SomethingByArrayHandleVoid s = handle.attach(SomethingByArrayHandleVoid.class); final List<Something> out = s.get(new int[]{1, 2}); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByIterableWithIterable() { final SomethingByIterable s = handle.attach(SomethingByIterable.class); final List<Something> out = s.get(() -> Arrays.asList(new SomethingKey(1, "1"), new SomethingKey(2, "2")) .iterator()); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void shouldRegisterMetrics() { BulkheadRegistry bulkheadRegistry = BulkheadRegistry.ofDefaults(); bulkheadRegistry.bulkhead("testName"); BulkheadMetrics bulkheadMetrics = BulkheadMetrics.ofBulkheadRegistry(bulkheadRegistry); bulkheadMetrics.bindTo(meterRegistry); final List<String> metricNames = meterRegistry.getMeters() .stream() .map(Meter::getId) .map(Meter.Id::getName) .collect(Collectors.toList()); final List<String> expectedMetrics = newArrayList( "resilience4j.bulkhead.testName.available_concurrent_calls"); assertThat(metricNames).hasSameElementsAs(expectedMetrics); }
@Test public void shouldRegisterMetrics() { RateLimiterRegistry rateLimiterRegistry = RateLimiterRegistry.ofDefaults(); rateLimiterRegistry.rateLimiter("testName"); RateLimiterMetrics rateLimiterMetrics = RateLimiterMetrics.ofRateLimiterRegistry(rateLimiterRegistry); rateLimiterMetrics.bindTo(meterRegistry); final List<String> metricNames = meterRegistry.getMeters() .stream() .map(Meter::getId) .map(Meter.Id::getName) .collect(Collectors.toList()); final List<String> expectedMetrics = newArrayList( "resilience4j.ratelimiter.testName.available_permissions", "resilience4j.ratelimiter.testName.number_of_waiting_threads"); assertThat(metricNames).hasSameElementsAs(expectedMetrics); }
@Test public void testSomethingByIterableWithIterable() { final SomethingByIterable s = handle.attach(SomethingByIterable.class); final List<Something> out = s.get(() -> Arrays.asList(new SomethingKey(1, "1"), new SomethingKey(2, "2")) .iterator()); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testGetEndpointGroup() { await().untilAsserted(() -> assertThat(endpointGroup.endpoints()).hasSameElementsAs(sampleEndpoints)); }
@Test public void testSomethingWithExplicitAttributeName() { final SomethingWithExplicitAttributeName s = handle.attach(SomethingWithExplicitAttributeName.class); final List<Something> out = s.get( new SomethingKey(1, "1"), new SomethingKey(2, "2")); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingWithExplicitAttributeName() { final SomethingWithExplicitAttributeName s = handle.attach(SomethingWithExplicitAttributeName.class); final List<Something> out = s.get( new SomethingKey(1, "1"), new SomethingKey(2, "2")); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByVarargsWithVarargs() { final SomethingByVarargs s = handle.attach(SomethingByVarargs.class); final List<Something> out = s.get( new SomethingKey(1, "1"), new SomethingKey(2, "2")); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByArrayWithNonEmptyArray() { final SomethingByVarargs s = handle.attach(SomethingByVarargs.class); final List<Something> out = s.get( new SomethingKey(1, "1"), new SomethingKey(2, "2")); assertThat(out).hasSameElementsAs(expectedSomethings); }
@Test public void testSomethingByArrayWithNonEmptyArray() { final SomethingByVarargs s = handle.attach(SomethingByVarargs.class); final List<Something> out = s.get( new SomethingKey(1, "1"), new SomethingKey(2, "2")); assertThat(out).hasSameElementsAs(expectedSomethings); }