/** * @return A matcher matching any collection containing every element in elements * @deprecated Please use {@link CoreMatchers#hasItems(Object...)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> hasItems(T... elements) { return CoreMatchers.hasItems(elements); }
/** * @return A matcher matching any collection containing at least one element that matches * each matcher in elementMatcher (this may be one element matching all matchers, * or different elements matching each matcher) * @deprecated Please use {@link CoreMatchers#hasItems(Matcher...)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... elementMatchers) { return CoreMatchers.hasItems(elementMatchers); }
/** * @return A matcher matching any collection containing at least one element that matches * each matcher in elementMatcher (this may be one element matching all matchers, * or different elements matching each matcher) * @deprecated Please use {@link CoreMatchers#hasItems(Matcher...)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> hasItems(Matcher<? super T>... elementMatchers) { return CoreMatchers.hasItems(elementMatchers); }
/** * @return A matcher matching any collection containing every element in elements * @deprecated Please use {@link CoreMatchers#hasItems(Object...)} instead. */ @Deprecated public static <T> Matcher<Iterable<T>> hasItems(T... elements) { return CoreMatchers.hasItems(elements); }
@Test public void shouldGetAllEntries() { assertThat(config.entries().size(), is(2)); assertThat(config.entries(), hasItems(E1, E2)); }
@SuppressWarnings("unchecked") private static Matcher<Iterable<List<String>>> hasItems(final TestResult expected) { return CoreMatchers.hasItems(expected.rows().stream() .map(CoreMatchers::equalTo) .toArray(Matcher[]::new)); }
private void assertTags(SqliteJobQueue queue, TagInfo... expected) { List<TagInfo> tags = loadAllTags(queue); assertThat(tags, hasItems(expected)); assertThat(tags.size(), is(expected.length)); }
@Test public void buildContextHierarchyMapForTestClassHierarchyWithMultiLevelContextHierarchiesAndPartiallyNamedConfig() { Map<String, List<ContextConfigurationAttributes>> map = buildContextHierarchyMap(TestClass2WithMultiLevelContextHierarchyAndPartiallyNamedConfig.class); String level1 = "parent"; String level2 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 2; String level3 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 3; assertThat(map.size(), is(3)); assertThat(map.keySet(), hasItems(level1, level2, level3)); Iterator<String> levels = map.keySet().iterator(); assertThat(levels.next(), is(level1)); assertThat(levels.next(), is(level2)); assertThat(levels.next(), is(level3)); List<ContextConfigurationAttributes> level1Config = map.get(level1); assertThat(level1Config.size(), is(2)); assertThat(level1Config.get(0).getLocations()[0], is("1-A.xml")); assertThat(level1Config.get(1).getLocations()[0], is("2-A.xml")); List<ContextConfigurationAttributes> level2Config = map.get(level2); assertThat(level2Config.size(), is(1)); assertThat(level2Config.get(0).getLocations()[0], is("1-B.xml")); List<ContextConfigurationAttributes> level3Config = map.get(level3); assertThat(level3Config.size(), is(1)); assertThat(level3Config.get(0).getLocations()[0], is("2-C.xml")); }
@Test public void buildContextHierarchyMapForTestClassHierarchyWithMultiLevelContextHierarchies() { Map<String, List<ContextConfigurationAttributes>> map = buildContextHierarchyMap(TestClass3WithMultiLevelContextHierarchy.class); assertThat(map.size(), is(3)); assertThat(map.keySet(), hasItems("alpha", "beta", "gamma")); List<ContextConfigurationAttributes> alphaConfig = map.get("alpha"); assertThat(alphaConfig.size(), is(3)); assertThat(alphaConfig.get(0).getLocations()[0], is("1-A.xml")); assertThat(alphaConfig.get(1).getLocations()[0], is("2-A.xml")); assertThat(alphaConfig.get(2).getLocations()[0], is("3-A.xml")); List<ContextConfigurationAttributes> betaConfig = map.get("beta"); assertThat(betaConfig.size(), is(3)); assertThat(betaConfig.get(0).getLocations()[0], is("1-B.xml")); assertThat(betaConfig.get(1).getLocations()[0], is("2-B.xml")); assertThat(betaConfig.get(2).getLocations()[0], is("3-B.xml")); List<ContextConfigurationAttributes> gammaConfig = map.get("gamma"); assertThat(gammaConfig.size(), is(1)); assertThat(gammaConfig.get(0).getLocations()[0], is("3-C.xml")); }
@Test public void shouldNotIncludeSslPropertiesInListPropertiesOutput() { // When: final PropertiesList props = makeSingleRequest("list properties;", PropertiesList.class); // Then: assertThat(props.getProperties().keySet(), not(hasItems(KsqlConfig.SSL_CONFIG_NAMES.toArray(new String[0])))); }
@Test public void buildContextHierarchyMapForTestClassHierarchyWithMultiLevelContextHierarchiesAndUnnamedConfig() { Map<String, List<ContextConfigurationAttributes>> map = buildContextHierarchyMap(TestClass3WithMultiLevelContextHierarchyAndUnnamedConfig.class); String level1 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 1; String level2 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 2; String level3 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 3; String level4 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 4; String level5 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 5; String level6 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 6; String level7 = GENERATED_CONTEXT_HIERARCHY_LEVEL_PREFIX + 7; assertThat(map.size(), is(7)); assertThat(map.keySet(), hasItems(level1, level2, level3, level4, level5, level6, level7)); List<ContextConfigurationAttributes> level1Config = map.get(level1); assertThat(level1Config.size(), is(1)); assertThat(level1Config.get(0).getLocations()[0], is("1-A.xml")); List<ContextConfigurationAttributes> level2Config = map.get(level2); assertThat(level2Config.size(), is(1)); assertThat(level2Config.get(0).getLocations()[0], is("1-B.xml")); List<ContextConfigurationAttributes> level3Config = map.get(level3); assertThat(level3Config.size(), is(1)); assertThat(level3Config.get(0).getLocations()[0], is("2-A.xml")); // ... List<ContextConfigurationAttributes> level7Config = map.get(level7); assertThat(level7Config.size(), is(1)); assertThat(level7Config.get(0).getLocations()[0], is("3-C.xml")); }
@Test public void shouldFlattenDeepNestedLists_stream() throws Exception { List<String> flatten = P07.flatten_stream(asList("a", asList("b", asList("c", asList("d", "e", asList("f", "g"))), "h")), String.class); assertThat(flatten, hasSize(8)); assertThat(flatten, hasItems("a", "b", "c", "d", "e", "f", "g", "h")); } }
@Test public void shouldFlattenDeepNestedLists() throws Exception { List<String> flatten = P07.flatten(asList("a", asList("b", asList("c", asList("d", "e", asList("f", "g"))), "h")), String.class); assertThat(flatten, hasSize(8)); assertThat(flatten, hasItems("a", "b", "c", "d", "e", "f", "g", "h")); }
/** * Used to reproduce bug reported in https://jira.spring.io/browse/SPR-10997 */ @Test public void buildContextHierarchyMapForTestClassHierarchyWithMultiLevelContextHierarchiesAndOverriddenInitializers() { Map<String, List<ContextConfigurationAttributes>> map = buildContextHierarchyMap(TestClass2WithMultiLevelContextHierarchyWithOverriddenInitializers.class); assertThat(map.size(), is(2)); assertThat(map.keySet(), hasItems("alpha", "beta")); List<ContextConfigurationAttributes> alphaConfig = map.get("alpha"); assertThat(alphaConfig.size(), is(2)); assertThat(alphaConfig.get(0).getLocations().length, is(1)); assertThat(alphaConfig.get(0).getLocations()[0], is("1-A.xml")); assertThat(alphaConfig.get(0).getInitializers().length, is(0)); assertThat(alphaConfig.get(1).getLocations().length, is(0)); assertThat(alphaConfig.get(1).getInitializers().length, is(1)); assertEquals(DummyApplicationContextInitializer.class, alphaConfig.get(1).getInitializers()[0]); List<ContextConfigurationAttributes> betaConfig = map.get("beta"); assertThat(betaConfig.size(), is(2)); assertThat(betaConfig.get(0).getLocations().length, is(1)); assertThat(betaConfig.get(0).getLocations()[0], is("1-B.xml")); assertThat(betaConfig.get(0).getInitializers().length, is(0)); assertThat(betaConfig.get(1).getLocations().length, is(0)); assertThat(betaConfig.get(1).getInitializers().length, is(1)); assertEquals(DummyApplicationContextInitializer.class, betaConfig.get(1).getInitializers()[0]); }
@Test public void shouldFlattenAListOfList() throws Exception { List<String> flatten = P07.flatten(asList("a", asList("b", asList("c", "d")), "e"), String.class); assertThat(flatten, hasSize(5)); assertThat(flatten, hasItems("a", "b", "c", "d", "e")); }
@Test public void shouldFlattenAListOfList_stream() throws Exception { List<String> flatten = P07.flatten_stream(asList("a", asList("b", asList("c", "d")), "e"), String.class); assertThat(flatten, hasSize(5)); assertThat(flatten, hasItems("a", "b", "c", "d", "e")); }
@SuppressWarnings("unchecked") @Test public void multiStringHeaderValueWithMatchers() throws Exception { this.mockMvc.perform(get("/persons/1")) .andExpect(header().stringValues(VARY, hasItems(containsString("foo"), startsWith("bar")))); }
@Test public void shouldReturnSameListWhenListHasNoNestedList() throws Exception { List<String> flatten = P07.flatten(asList("a", "b", "c", "d", "e"), String.class); assertThat(flatten, hasSize(5)); assertThat(flatten, hasItems("a", "b", "c", "d", "e")); }
@Test public void testGetAllHFileRefsCversionChange() throws IOException, ReplicationException { ZKReplicationQueueStorage storage = createWithUnstableVersion(); storage.addPeerToHFileRefs("1"); Path p = new Path("/test"); storage.addHFileRefs("1", Arrays.asList(Pair.newPair(p, p))); // This should return eventually when cversion stabilizes Set<String> allHFileRefs = storage.getAllHFileRefs(); assertEquals(1, allHFileRefs.size()); assertThat(allHFileRefs, hasItems("test")); }
@Test public void testGetAllWALsCversionChange() throws IOException, ReplicationException { ZKReplicationQueueStorage storage = createWithUnstableVersion(); storage.addWAL(getServerName(0), "1", "file"); // This should return eventually when cversion stabilizes Set<String> allWals = storage.getAllWALs(); assertEquals(1, allWals.size()); assertThat(allWals, hasItems("file")); }