@Test public void testExecuteWithNoSkills() { fields.put("skills", ""); context.checking(new Expectations() { { oneOf(persistResourceExecutionMock).execute(with(any(TaskHandlerActionContext.class))); will(returnValue(personMock)); oneOf(personMock).getOpenSocialId(); will(returnValue("53")); oneOf(backgroundMapperMock).findOrCreatePersonBackground("53"); oneOf(personMapperMock).flush(); oneOf(personMock).getId(); will(returnValue(5L)); oneOf(deleteCacheKeyDAO).execute(Collections.singleton(CacheKeys.PERSON_BY_ID + 5L)); } }); sut.execute(TestContextCreator.createTaskHandlerContextWithPrincipal(fields, principalMock)); context.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) throws ExecutionException { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getActionContext().getParams(); fields.remove("isAdministrator"); fields.remove(PersonModelView.CELLPHONE_KEY); fields.remove(PersonModelView.FAX_KEY); log.debug("Updating person with fields: " + fields.keySet()); Person person = (Person) personPersister.execute(inActionContext); List<BackgroundItem> skills = convertStringToBackgroundItems((String) fields.get(PersonModelView.SKILLS_KEY), BackgroundItemType.SKILL); Background background = backgroundMapper.findOrCreatePersonBackground(person.getOpenSocialId()); background.setBackgroundItems(skills, BackgroundItemType.SKILL); personMapper.flush(); deleteCacheKeyDAO.execute(Collections.singleton(CacheKeys.PERSON_BY_ID + person.getId())); return person; }
UpdatePersonExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) throws ExecutionException { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getActionContext().getParams(); fields.remove("isAdministrator"); fields.remove(PersonModelView.CELLPHONE_KEY); fields.remove(PersonModelView.FAX_KEY); log.debug("Updating person with fields: " + fields.keySet()); Person person = (Person) personPersister.execute(inActionContext); List<BackgroundItem> skills = convertStringToBackgroundItems((String) fields.get(PersonModelView.SKILLS_KEY), BackgroundItemType.SKILL); Background background = backgroundMapper.findOrCreatePersonBackground(person.getOpenSocialId()); background.setBackgroundItems(skills, BackgroundItemType.SKILL); personMapper.flush(); deleteCacheKeyDAO.execute(Collections.singleton(CacheKeys.PERSON_BY_ID + person.getId())); return person; } }
UpdatePersonExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) throws ExecutionException { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getActionContext().getParams(); fields.remove("isAdministrator"); fields.remove(PersonModelView.CELLPHONE_KEY); fields.remove(PersonModelView.FAX_KEY); log.debug("Updating person with fields: " + fields.keySet()); Person person = (Person) personPersister.execute(inActionContext); List<BackgroundItem> skills = convertStringToBackgroundItems((String) fields.get(PersonModelView.SKILLS_KEY), BackgroundItemType.SKILL); Background background = backgroundMapper.findOrCreatePersonBackground(person.getOpenSocialId()); background.setBackgroundItems(skills, BackgroundItemType.SKILL); personMapper.flush(); deleteCacheKeyDAO.execute(Collections.singleton(CacheKeys.PERSON_BY_ID + person.getId())); return person; } UpdatePersonExecution(final PersonMapper inPersonMapper,
            final TaskHandlerExecutionStrategy inPersonPersister, final BackgroundMapper inBackgroundMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeyDAO); }
UpdatePersonExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) throws ExecutionException { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getActionContext().getParams(); fields.remove("isAdministrator"); fields.remove(PersonModelView.CELLPHONE_KEY); fields.remove(PersonModelView.FAX_KEY); log.debug("Updating person with fields: " + fields.keySet()); Person person = (Person) personPersister.execute(inActionContext); List<BackgroundItem> skills = convertStringToBackgroundItems((String) fields.get(PersonModelView.SKILLS_KEY), BackgroundItemType.SKILL); Background background = backgroundMapper.findOrCreatePersonBackground(person.getOpenSocialId()); background.setBackgroundItems(skills, BackgroundItemType.SKILL); personMapper.flush(); deleteCacheKeyDAO.execute(Collections.singleton(CacheKeys.PERSON_BY_ID + person.getId())); return person; } UpdatePersonExecution(final PersonMapper inPersonMapper,
            final TaskHandlerExecutionStrategy inPersonPersister, final BackgroundMapper inBackgroundMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeyDAO); @Override // TODO: This is a weird mix of wrapping PersistResourceAction with another execution strategy and they are // each fiddling with the update in different ways. This needs to be refactored. It's at best non-standard // and error-prone in it's current state. Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext); }
UpdatePersonExecution implements TaskHandlerExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext) throws ExecutionException { Map<String, Serializable> fields = (Map<String, Serializable>) inActionContext.getActionContext().getParams(); fields.remove("isAdministrator"); fields.remove(PersonModelView.CELLPHONE_KEY); fields.remove(PersonModelView.FAX_KEY); log.debug("Updating person with fields: " + fields.keySet()); Person person = (Person) personPersister.execute(inActionContext); List<BackgroundItem> skills = convertStringToBackgroundItems((String) fields.get(PersonModelView.SKILLS_KEY), BackgroundItemType.SKILL); Background background = backgroundMapper.findOrCreatePersonBackground(person.getOpenSocialId()); background.setBackgroundItems(skills, BackgroundItemType.SKILL); personMapper.flush(); deleteCacheKeyDAO.execute(Collections.singleton(CacheKeys.PERSON_BY_ID + person.getId())); return person; } UpdatePersonExecution(final PersonMapper inPersonMapper,
            final TaskHandlerExecutionStrategy inPersonPersister, final BackgroundMapper inBackgroundMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteCacheKeyDAO); @Override // TODO: This is a weird mix of wrapping PersistResourceAction with another execution strategy and they are // each fiddling with the update in different ways. This needs to be refactored. It's at best non-standard // and error-prone in it's current state. Serializable execute(final TaskHandlerActionContext<PrincipalActionContext> inActionContext);  }