public void multipleDependants() throws Exception {
String idPrefix = newIdPrefix();
final SchemaId dummyVtag = ids.getSchemaId(UUID.randomUUID());
final SchemaId dependencyField = ids.getSchemaId(UUID.randomUUID());
final RecordId dependant1 = ids.newRecordId(idPrefix + "dependant1");
final RecordId dependant2 = ids.newRecordId(idPrefix + "dependant2");
final RecordId dependency = ids.newRecordId(idPrefix + "dependency");
// the dependant1 and dependant2 depend on the dependencyField of the dependency
final HashMap<DependencyEntry, Set<SchemaId>> dependencies =
new HashMap<DependencyEntry, Set<SchemaId>>();
dependencies.put(new DependencyEntry(absId(dependency)),
Sets.newHashSet(dependencyField));
derefMap.updateDependants(absId(dependant1), dummyVtag, dependencies);
derefMap.updateDependants(absId(dependant2), dummyVtag, dependencies);
// consistency check dependant1
final Set<DependencyEntry> dependenciesOf1 = derefMap.findDependencies(absId(dependant1), dummyVtag);
assertEquals(1, dependenciesOf1.size());
assertEquals(absId(dependency.getMaster()), dependenciesOf1.iterator().next().getDependency());
// consistency check dependant2
final Set<DependencyEntry> dependenciesOf2 = derefMap.findDependencies(absId(dependant1), dummyVtag);
assertEquals(1, dependenciesOf2.size());
assertEquals(absId(dependency.getMaster()), dependenciesOf2.iterator().next().getDependency());
// check that both dependant1 and dependant2 are found as dependants of the dependency
final DependantRecordIdsIterator dependants =
derefMap.findDependantsOf(absId(dependency), dependencyField, dummyVtag);
assertTrue(dependants.hasNext());