AccessReferenceMapperImpl implements AccessReferenceMapper { @Override public void setupAccessReferenceMap(Iterable<? extends HasId> objects) { HttpSession session = getSession(); AccessReferenceMap<String> map = getMap(); for (HasId o : objects) { String indirectReference = map.addDirectReference(o.getId()); o.setId(indirectReference); } session.setAttribute("AccessReferenceMap", map); }  @Override long getDirectReference(String indirectReference); @Override String getIndirectReference(String directReference); @Override void setupAccessReferenceMap(Iterable<? extends HasId> objects);  }
@Test public void testSetupAccessReferenceMap() { Set<HasId> objectSet = new HashSet<HasId>(); HasId hasId1 = mock(HasId.class); HasId hasId2 = mock(HasId.class); objectSet.add(hasId1); objectSet.add(hasId2); doReturn("1").when(hasId1).getId(); doReturn("2").when(hasId2).getId(); sut.setupAccessReferenceMap(objectSet); verify(hasId1).setId(INDIRECT_REFERENCE); verify(hasId2).setId(INDIRECT_REFERENCE); }