@Test public final void testPersistWithSameDisplayName() throws Exception { final Person testPerson = new Person("accountid", "First", "Middle", "Last", "Preferred"); final List<Person> attribMembers = new ArrayList<Person>(); attribMembers.add(new Person("id", "Homer", "Jay", "Simpson", "Homey")); attribMembers.add(new Person("id", "Max", "X", "Power", "Homer")); final List<Person> groupMembers = new ArrayList<Person>(); groupMembers.add(new Person("id", "Homer", "Jay", "Simpson", "Homey")); groupMembers.add(new Person("id", "Max", "X", "Power", "Homer")); final long id = 1L; String newName = "NEW org name here"; final HashMap<String, Serializable> formData = new HashMap<String, Serializable>(); formData.put("id", Long.toString(id)); formData.put("name", newName); formData.put("membershipcriteria", "somegroup"); formData.put(PersonUpdater.ORIGINAL_DISPLAY_NAME_KEY, "Preferred Last"); context.checking(new Expectations() { { oneOf(personMapperMock).flush(); } }); sut.persist(taskHandlerActionContext, formData, testPerson); context.assertIsSatisfied(); }
public void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields, final Person inUpdatedPerson) throws Exception { String originalDisplayName = (String) inFields.get(ORIGINAL_DISPLAY_NAME_KEY); String newDisplayName = inUpdatedPerson.getDisplayName(); if (originalDisplayName == null || !originalDisplayName.equals(newDisplayName)) { if (log.isInfoEnabled()) { log.info("Person with account id " + inUpdatedPerson.getAccountId() + " display name is updated from " + originalDisplayName + " to " + newDisplayName); } inActionContext.getUserActionRequests().addAll( personActivityCacheUpdater.getUpdateCacheRequests( inActionContext.getActionContext().getPrincipal(), inUpdatedPerson.getId())); } personMapper.flush(); }
PersonUpdater implements ResourcePersistenceStrategy<Person> { public void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields, final Person inUpdatedPerson) throws Exception { String originalDisplayName = (String) inFields.get(ORIGINAL_DISPLAY_NAME_KEY); String newDisplayName = inUpdatedPerson.getDisplayName(); if (originalDisplayName == null || !originalDisplayName.equals(newDisplayName)) { if (log.isInfoEnabled()) { log.info("Person with account id " + inUpdatedPerson.getAccountId() + " display name is updated from " + originalDisplayName + " to " + newDisplayName); } inActionContext.getUserActionRequests().addAll( personActivityCacheUpdater.getUpdateCacheRequests( inActionContext.getActionContext().getPrincipal(), inUpdatedPerson.getId())); } personMapper.flush(); } }
PersonUpdater implements ResourcePersistenceStrategy<Person> { public void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields, final Person inUpdatedPerson) throws Exception { String originalDisplayName = (String) inFields.get(ORIGINAL_DISPLAY_NAME_KEY); String newDisplayName = inUpdatedPerson.getDisplayName(); if (originalDisplayName == null || !originalDisplayName.equals(newDisplayName)) { if (log.isInfoEnabled()) { log.info("Person with account id " + inUpdatedPerson.getAccountId() + " display name is updated from " + originalDisplayName + " to " + newDisplayName); } inActionContext.getUserActionRequests().addAll( personActivityCacheUpdater.getUpdateCacheRequests( inActionContext.getActionContext().getPrincipal(), inUpdatedPerson.getId())); } personMapper.flush(); } PersonUpdater(final PersonMapper inPersonMapper, final CacheUpdater inPersonActivityCacheUpdater); }
PersonUpdater implements ResourcePersistenceStrategy<Person> { public void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields, final Person inUpdatedPerson) throws Exception { String originalDisplayName = (String) inFields.get(ORIGINAL_DISPLAY_NAME_KEY); String newDisplayName = inUpdatedPerson.getDisplayName(); if (originalDisplayName == null || !originalDisplayName.equals(newDisplayName)) { if (log.isInfoEnabled()) { log.info("Person with account id " + inUpdatedPerson.getAccountId() + " display name is updated from " + originalDisplayName + " to " + newDisplayName); } inActionContext.getUserActionRequests().addAll( personActivityCacheUpdater.getUpdateCacheRequests( inActionContext.getActionContext().getPrincipal(), inUpdatedPerson.getId())); } personMapper.flush(); } PersonUpdater(final PersonMapper inPersonMapper, final CacheUpdater inPersonActivityCacheUpdater); Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields); void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields, final Person inUpdatedPerson); }
PersonUpdater implements ResourcePersistenceStrategy<Person> { public void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext, final Map<String, Serializable> inFields, final Person inUpdatedPerson) throws Exception { String originalDisplayName = (String) inFields.get(ORIGINAL_DISPLAY_NAME_KEY); String newDisplayName = inUpdatedPerson.getDisplayName(); if (originalDisplayName == null || !originalDisplayName.equals(newDisplayName)) { if (log.isInfoEnabled()) { log.info("Person with account id " + inUpdatedPerson.getAccountId() + " display name is updated from " + originalDisplayName + " to " + newDisplayName); } inActionContext.getUserActionRequests().addAll( personActivityCacheUpdater.getUpdateCacheRequests( inActionContext.getActionContext().getPrincipal(), inUpdatedPerson.getId())); } personMapper.flush(); } PersonUpdater(final PersonMapper inPersonMapper, final CacheUpdater inPersonActivityCacheUpdater); Person get(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields); void persist(final TaskHandlerActionContext<PrincipalActionContext> inActionContext,
            final Map<String, Serializable> inFields, final Person inUpdatedPerson); static final String ORIGINAL_PARENT_ORG_KEY; }