### Question:
DevicePrintDao { void saveProfiles(AMIdentityWrapper amIdentity, List<Map<String, Object>> profiles) { try { Set<String> vals = new HashSet<String>(); for (Map<String, Object> profile : profiles) { StringWriter writer = new StringWriter(); MAPPER.writeValue(writer, profile); vals.add(writer.toString()); } Map<String, Set> profilesMap = new HashMap<String, Set>(); profilesMap.put(LDAP_DEVICE_PRINT_ATTRIBUTE_NAME, vals); amIdentity.setAttributes(profilesMap); amIdentity.store(); DEBUG.message("Profiles stored"); } catch (Exception e) { DEBUG.error("Could not store profiles. " + e); } }    }### Answer:
@Test public void shouldSaveProfiles() throws IOException, IdRepoException, SSOException { AMIdentityWrapper amIdentity = mock(AMIdentityWrapper.class); List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>(); Map<String, Object> profileOne = new HashMap<String, Object>(); profileOne.put("uuid", "UUID1"); profileOne.put("lastSelectedDate", new Date(newDate().getTime() - 172800)); Map<String, Object> profileTwo = new HashMap<String, Object>(); profileTwo.put("uuid", "UUID2"); profileTwo.put("lastSelectedDate", new Date(newDate().getTime() - 86400)); profiles.add(profileOne); profiles.add(profileTwo); devicePrintDao.saveProfiles(amIdentity, profiles); ArgumentCaptor<Map> ldapProfilesCaptor = ArgumentCaptor.forClass(Map.class); verify(amIdentity).setAttributes(ldapProfilesCaptor.capture()); verify(amIdentity).store(); Map ldapProfiles = ldapProfilesCaptor.getValue(); assertThat(((Set) ldapProfiles.get("devicePrintProfiles"))).hasSize(2); }
@Test public void shouldSaveProfiles() throws IOException, IdRepoException, SSOException { AMIdentityWrapper amIdentity = mock(AMIdentityWrapper.class); List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>(); Map<String, Object> profileOne = new HashMap<String, Object>(); profileOne.put("uuid", "UUID1"); profileOne.put("lastSelectedDate", new Date(new Date().getTime() - 172800)); Map<String, Object> profileTwo = new HashMap<String, Object>(); profileTwo.put("uuid", "UUID2"); profileTwo.put("lastSelectedDate", new Date(new Date().getTime() - 86400)); profiles.add(profileOne); profiles.add(profileTwo); devicePrintDao.saveProfiles(amIdentity, profiles); ArgumentCaptor<Map> ldapProfilesCaptor = ArgumentCaptor.forClass(Map.class); verify(amIdentity).setAttributes(ldapProfilesCaptor.capture()); verify(amIdentity).store(); Map ldapProfiles = ldapProfilesCaptor.getValue(); assertThat(((Set) ldapProfiles.get("devicePrintProfiles"))).hasSize(2); }