KeyTreeMap { public MultiMap<Value, T, List<T>> get(final KeyDefinition keyDefinition) { return tree.get(keyDefinition); } KeyTreeMap(final KeyDefinition... keyIDs); void put(final T object); MultiMap<Value, T, List<T>> get(final KeyDefinition keyDefinition); void merge(final KeyTreeMap<T> keyTreeMap);  }
@Test public void testFindByUUID() throws Exception { Util.assertMapContent(map.get(UUIDKey.UNIQUE_UUID), toni.uuidKey, eder.uuidKey, michael.uuidKey); }
@Test public void testFindByName() throws Exception { Util.assertMapContent(map.get(KeyDefinition.newKeyDefinition() .withId("name") .build()), "Toni", "Eder", "Michael"); }
@Test public void testFindByAge() throws Exception { final MultiMap<Value, Person, List<Person>> age = map.get(KeyDefinition.newKeyDefinition() .withId("age") .build()); Util.assertMapContent(age, 20, 20, 30); assertTrue(age.get(new Value(20)) .contains(toni)); assertTrue(age.get(new Value(20)) .contains(eder)); }
@Test public void testUpdateAge() throws Exception { final MultiMapChangeHandler changeHandler = mock(MultiMapChangeHandler.class); ((ChangeHandledMultiMap) map.get(AGE)).addChangeListener(changeHandler); toni.setAge(10); final MultiMap<Value, Person, List<Person>> age = map.get(AGE); assertFalse(age.get(new Value(20)) .contains(toni)); assertTrue(age.get(new Value(10)) .contains(toni)); }
@Test public void testRetract() throws Exception { toni.uuidKey.retract(); Util.assertMapContent(map.get(UUIDKey.UNIQUE_UUID), eder.uuidKey, michael.uuidKey); Util.assertMapContent(map.get(KeyDefinition.newKeyDefinition() .withId("name") .build()), "Eder", "Michael"); Util.assertMapContent(map.get(KeyDefinition.newKeyDefinition() .withId("age") .build()), 20, 30); }