* not expected
*/
@Test
public void persistSuccessWithNewCoordinators() throws Exception
{
final DomainGroup group = new DomainGroup("Group Name", "shortName", new Person("id1", "Homer", "Jay",
"Simpson", "Homey"));
final Set<Person> attribMembers = new HashSet<Person>();
attribMembers.add(new Person("id1", "Homer", "Jay", "Simpson", "Homey"));
attribMembers.add(new Person("id2", "Max", "X", "Power", "Homer"));
group.setCoordinators(new HashSet(attribMembers));
group.getCoordinators().add(new Person("id3", "A", "New", "Member", "Guy"));
final long id = 1L;
String newName = "NEW group name here";
final HashMap<String, Serializable> formData = new HashMap<String, Serializable>();
formData.put(DomainGroupModelView.ID_KEY, Long.toString(id));
formData.put(DomainGroupModelView.NAME_KEY, newName);
formData.put(DomainGroupModelView.KEYWORDS_KEY, "good,idea");
formData.put(DomainGroupModelView.COORDINATORS_KEY, (Serializable) group.getCoordinators());
formData.put("__KEY_ORIGINAL_GROUP_NAME_KEY", "Group Name");
formData.put("__KEY_ORIGINAL_GROUP_COORDINATORS_KEY", (Serializable) attribMembers);
context.checking(new Expectations()
{
{
ignoring(taskHandlerActionContext);
allowing(taskHandlerActionContext).getActionContext();
will(returnValue(actionContext));
ignoring(actionContext);
allowing(actionContext).getPrincipal();
will(returnValue(userPrincipal));
ignoring(userPrincipal);
oneOf(groupMapperMock).flush();
oneOf(followStrategyMock).execute(with(any(TaskHandlerActionContext.class)));
// TODO: consider making a fake so we can make sure the right
// action was called
// oneOf(taskHandler).handleTask(with(any(UserActionRequest.class)));
}
});
sut.persist(taskHandlerActionContext, formData, group);
context.assertIsSatisfied();
assertEquals("Group Name", group.getName());
// TODO Could be more thorough - a list compare utility would help
assertEquals(2, group.getCapabilities().size());
// make sure the only queued task is the domain group cache update
assertEquals(1, taskHandlerActionContext.getUserActionRequests().size());
assertEquals("domainGroupCacheUpdaterAsyncAction", taskHandlerActionContext.getUserActionRequests().get(0)
.getActionKey());