PermissionSubjectsMap extends AbstractMap<String, Map<String, Integer>> { void addTotalRelationOfWeightZero(final Iterable<String> permissions, final Collection<String> subjectIds) { validatePermissions(permissions); validateSubjectIds(subjectIds); final Map<String, Integer> subjectsWithDefaultWeight = subjectIds.stream() .collect(Collectors.toMap(Function.identity(), subject -> 0)); permissions.forEach(permission -> addPermissionSubjects(permission, subjectsWithDefaultWeight)); } PermissionSubjectsMap(); @Override Set<Entry<String, Map<String, Integer>>> entrySet(); @Override Map<String, Integer> put(final String key, final Map<String, Integer> value); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void addTotalRelationOfWeightZeroWorksAsExpected() { final Map<String, Integer> weightedSubjectIds = weighSubjectIds(0); underTest.addTotalRelationOfWeightZero(permissions, subjectIds); assertThat(underTest) .hasSameSizeAs(permissions) .containsEntry("READ", weightedSubjectIds) .containsEntry("WRITE", weightedSubjectIds); }