public 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 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 void test_ofChained_chainRemoveSections() { IniFile test = ResourceConfig.combinedIniFile("TestChain5.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "a"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n", "o", "z"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_equalsHashCode() { Map<String, String> keyValues = ImmutableMap.of("a", "x", "b", "y"); PropertySet a1 = PropertySet.of(keyValues); PropertySet a2 = PropertySet.of(keyValues); PropertySet b = PropertySet.of(ImmutableMap.of("a", "x", "b", "z")); assertEquals(a1.equals(a1), true); assertEquals(a1.equals(a2), true); assertEquals(a1.equals(b), false); assertEquals(a1.equals(null), false); assertEquals(a1.equals(ANOTHER_TYPE), false); assertEquals(a1.hashCode(), a2.hashCode()); }
public void test_ofChained_chainNextFileTrue() { IniFile test = ResourceConfig.combinedIniFile("TestChain1.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z", "b", "y"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_autoChain() { IniFile test = ResourceConfig.combinedIniFile("TestChain4.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z", "b", "y"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_chainNextFileFalse() { IniFile test = ResourceConfig.combinedIniFile("TestChain2.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "z"); Multimap<String, String> keyValues2 = ImmutableListMultimap.of("m", "n"); assertEquals( test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1), "two", PropertySet.of(keyValues2))); }
public void test_ofChained_chainToNowhere() { IniFile test = ResourceConfig.combinedIniFile("TestChain3.ini"); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "x", "b", "y"); assertEquals(test.asMap(), ImmutableMap.of("one", PropertySet.of(keyValues1))); }
public void test_overrideWith_emptyOther() { PropertySet base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); assertEquals(PropertySet.empty().overrideWith(base), base); }
public 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 void test_combinedWith_emptyOther() { PropertySet base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); assertEquals(PropertySet.empty().combinedWith(base), base); }
public void test_overrideWith_emptyBase() { PropertySet base = PropertySet.of(ImmutableListMultimap.of("a", "x", "a", "y", "b", "y", "c", "z")); assertEquals(base.overrideWith(PropertySet.empty()), base); }
public void test_of_escaping() { IniFile test = IniFile.of(CharSource.wrap(INI4)); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a=d=", "x"); assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1))); }
public void test_of_propertyNoEquals() { IniFile test = IniFile.of(CharSource.wrap("[section]\na\n")); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", ""); assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1))); assertEquals(test.section("section"), PropertySet.of(keyValues1)); assertEquals(test.section("section").contains("a"), true); assertEquals(test.section("section").valueList("a"), ImmutableList.of("")); assertEquals(test.section("section").contains("b"), false); assertEquals(test.section("section").keys(), ImmutableSet.of("a")); assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("a", "")); assertEquals(test.toString(), "{section={a=[]}}"); }
public void test_of_propertyNoEquals() { PropertiesFile test = PropertiesFile.of(CharSource.wrap("b\n")); Multimap<String, String> keyValues = ImmutableListMultimap.of("b", ""); assertEquals(test.getProperties(), PropertySet.of(keyValues)); assertEquals(test.toString(), "{b=[]}"); }
public void test_of_noLists() { PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE1)); Multimap<String, String> keyValues = ImmutableListMultimap.of("a", "x", "c", "z", "b", "y"); assertEquals(test.getProperties(), PropertySet.of(keyValues)); assertEquals(test.toString(), "{a=[x], c=[z], b=[y]}"); }
public void test_of_list() { PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE2)); Multimap<String, String> keyValues = ImmutableListMultimap.of("a", "x", "a", "y"); assertEquals(test.getProperties(), PropertySet.of(keyValues)); assertEquals(test.toString(), "{a=[x, y]}"); }
public void test_of_escaping() { PropertiesFile test = PropertiesFile.of(CharSource.wrap(FILE3)); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a=d=", "x"); assertEquals(test.getProperties(), PropertySet.of(keyValues1)); }
public void test_of_list() { IniFile test = IniFile.of(CharSource.wrap(INI3)); Multimap<String, String> keyValues1 = ImmutableListMultimap.of("a", "x", "a", "y"); assertEquals(test.asMap(), ImmutableMap.of("section", PropertySet.of(keyValues1))); assertEquals(test.section("section"), PropertySet.of(keyValues1)); assertEquals(test.section("section").contains("a"), true); assertThrowsIllegalArg(() -> test.section("section").value("a")); assertEquals(test.section("section").valueList("a"), ImmutableList.of("x", "y")); assertEquals(test.section("section").contains("b"), false); assertEquals(test.section("section").keys(), ImmutableSet.of("a")); assertEquals(test.section("section").asMultimap(), ImmutableListMultimap.of("a", "x", "a", "y")); assertEquals(test.toString(), "{section={a=[x, y]}}"); }