//------------------------------------------------------------------------- public virtual void toListMultimap() { IDictionary <string, int> map = ImmutableMap.of("a", 1, "aa", 2, "b", 10, "bb", 20, "c", 1); ListMultimap <string, int> expected = ImmutableListMultimap.of("a", 1, "a", 2, "b", 10, "b", 20, "c", 1); ListMultimap <string, int> result = MapStream.of(map).mapKeys(s => s.substring(0, 1)).toListMultimap(); assertThat(result).isEqualTo(expected); }
//------------------------------------------------------------------------- public virtual void test_combinedWith() { PropertySet @base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "c", "z")); PropertySet other = PropertySet.of(ImmutableListMultimap.of("a", "aa", "b", "bb", "d", "dd")); PropertySet expected = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "c", "z", "b", "bb", "d", "dd")); assertEquals(@base.combinedWith(other), expected); }
//------------------------------------------------------------------------- public virtual void test_overrideWith() { PropertySet @base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); PropertySet other = PropertySet.of(ImmutableListMultimap.of("a", "aa", "c", "cc", "d", "dd", "e", "ee")); PropertySet expected = PropertySet.of(ImmutableListMultimap.of("a", "aa", "b", "y", "c", "cc", "d", "dd", "e", "ee")); assertEquals(@base.overrideWith(other), expected); }
public virtual void test_of_multimap() { Multimap <string, string> keyValues = ImmutableMultimap.of("a", "x", "a", "y", "b", "z"); PropertySet test = PropertySet.of(keyValues); assertEquals(test.Empty, false); assertEquals(test.contains("a"), true); assertThrowsIllegalArg(() => test.value("a")); assertEquals(test.valueList("a"), ImmutableList.of("x", "y")); assertEquals(test.contains("b"), true); assertEquals(test.value("b"), "z"); assertEquals(test.valueList("b"), ImmutableList.of("z")); assertEquals(test.contains("c"), false); assertEquals(test.keys(), ImmutableSet.of("a", "b")); assertEquals(test.asMultimap(), ImmutableListMultimap.of("a", "x", "a", "y", "b", "z")); assertEquals(test.valueList("unknown"), ImmutableSet.of()); assertThrowsIllegalArg(() => test.asMap()); assertThrowsIllegalArg(() => test.value("unknown")); assertEquals(test.ToString(), "{a=[x, y], b=[z]}"); }
public virtual void test_combinedWith_emptyBase() { PropertySet @base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); assertEquals(@base.combinedWith(PropertySet.empty()), @base); }
public virtual void test_overrideWith_emptyOther() { PropertySet @base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); assertEquals(PropertySet.empty().overrideWith(@base), @base); }