+ config.values().add(mock(MyType.class));
+ }
+
+ @Test
+ public void testEquals() {
+
+ Config<MyType> config1 = new MyTypeConfig(CONFIG_TYPE);
+ assertFalse(config1.equals(null));
+ assertFalse(config1.equals("hello"));
+ Config<MyType> config2 = new MyTypeConfig(CONFIG_TYPE);
+
+ assertEquals(config1, config2);
+ assertEquals(config1.hashCode(), config2.hashCode());
+
+ MyType type1 = mock(MyType.class);
+ when(type1.getId()).thenReturn(new Id("type1"));
+
+ config1.add(type1);
+ assertFalse(config1.equals(config2));
+
+ MyType type2 = mock(MyType.class);
+ when(type2.getId()).thenReturn(new Id("type1"));
+
+ config2.add(type2);
+ assertEquals(config1, config2);
+ assertEquals(config1.hashCode(), config2.hashCode());
+
+ assertTrue(config2.remove(type2.getId()));
+ assertFalse(config1.equals(config2));
+ }
+
+ @Test
+ public void testCopy() {
+ testAdd();
+ assertEquals(2, config.values().size());
+ MyTypeConfig copy = new MyTypeConfig(config);
+ assertEquals(config.getPrefix(), copy.getPrefix());
+ assertEquals(config, copy);
+
+ // verify the copy is not shallow
+ assertTrue(config.remove(new Id<MyType>("type1")));
+ assertEquals(1, config.values().size());
+ assertFalse(config.equals(copy));