### Question:
ProfilePersister { void saveDevicePrint(Map<String, Object> devicePrint) { saveDevicePrint(null, devicePrint); } ProfilePersister(int maxProfilesAllowed, DevicePrintDao devicePrintDao, AMIdentityWrapper amIdentity);   }### Answer:
@Test public void shouldAddNewDevicePrintToProfiles() throws IOException, IdRepoException, SSOException { Map<String, Object> devicePrintProfile = new HashMap<String, Object>(); Map<String, Object> profileOne = new HashMap<String, Object>(); profileOne.put("uuid", "UUID1"); profileOne.put("lastSelectedDate", newDate().getTime() - 172800); Map<String, Object> profileTwo = new HashMap<String, Object>(); profileTwo.put("uuid", "UUID2"); profileTwo.put("lastSelectedDate", newDate().getTime() - 86400); List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>(); profiles.add(profileOne); profiles.add(profileTwo); given(devicePrintDao.getProfiles(amIdentity)).willReturn(profiles); profilePersister.saveDevicePrint(devicePrintProfile); ArgumentCaptor<List> profilesCaptor = ArgumentCaptor.forClass(List.class); verify(devicePrintDao).saveProfiles(eq(amIdentity), profilesCaptor.capture()); List<Map<String, Object>> savedProfiles = profilesCaptor.getValue(); assertThat(savedProfiles).hasSize(2); assertThat(savedProfiles.get(0)).containsEntry("uuid", "UUID2"); assertThat(savedProfiles.get(1)).doesNotContainEntry("uuid", "UUID1") .containsEntry("selectionCounter", 1) .containsKey("lastSelectedDate") .containsKey("devicePrint"); }
@Test public void shouldAddNewDevicePrintToProfiles() throws IOException, IdRepoException, SSOException { Map<String, Object> devicePrintProfile = new HashMap<String, Object>(); Map<String, Object> profileOne = new HashMap<String, Object>(); profileOne.put("uuid", "UUID1"); profileOne.put("lastSelectedDate", new Date().getTime() - 172800); Map<String, Object> profileTwo = new HashMap<String, Object>(); profileTwo.put("uuid", "UUID2"); profileTwo.put("lastSelectedDate", new Date().getTime() - 86400); List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>(); profiles.add(profileOne); profiles.add(profileTwo); given(devicePrintDao.getProfiles(amIdentity)).willReturn(profiles); profilePersister.saveDevicePrint(devicePrintProfile); ArgumentCaptor<List> profilesCaptor = ArgumentCaptor.forClass(List.class); verify(devicePrintDao).saveProfiles(eq(amIdentity), profilesCaptor.capture()); List<Map<String, Object>> savedProfiles = profilesCaptor.getValue(); assertThat(savedProfiles).hasSize(2); assertThat(savedProfiles.get(0)).containsEntry("uuid", "UUID2"); assertThat(savedProfiles.get(1)).doesNotContainEntry("uuid", "UUID1") .containsEntry("selectionCounter", 1) .containsKey("lastSelectedDate") .containsKey("devicePrint"); }