@Test public final void executeTest() { final Long personId = 2L; final Long scopeId = 3L; final Person person = context.mock(Person.class); final List<StreamScope> bookmarks = new ArrayList<StreamScope>(); final StreamScope scopeToAdd = new StreamScope(); context.checking(new Expectations() { { oneOf(actionContext).getPrincipal(); will(returnValue(principal)); oneOf(principal).getId(); will(returnValue(personId)); oneOf(personMapper).execute(with(any(FindByIdRequest.class))); will(returnValue(person)); oneOf(scopeMapper).execute(with(any(FindByIdRequest.class))); will(returnValue(scopeToAdd)); oneOf(person).getBookmarks(); will(returnValue(bookmarks)); allowing(actionContext).getParams(); will(returnValue(scopeId)); oneOf(personMapper).flush(); } }); sut.execute(actionContext); Assert.assertTrue(bookmarks.contains(scopeToAdd)); context.assertIsSatisfied(); }
public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { Long ssIdToInsert = (Long) inActionContext.getParams(); Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); List<StreamScope> bookmarks = person.getBookmarks(); StreamScope scope = null; for (StreamScope ss : bookmarks) { if (ss.getId() == ssIdToInsert) { scope = ss; break; } } if (scope == null) { scope = scopeMapper.execute(new FindByIdRequest("StreamScope", ssIdToInsert)); bookmarks.add(scope); personMapper.flush(); } return scope; }
InsertStreamBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { Long ssIdToInsert = (Long) inActionContext.getParams(); Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); List<StreamScope> bookmarks = person.getBookmarks(); StreamScope scope = null; for (StreamScope ss : bookmarks) { if (ss.getId() == ssIdToInsert) { scope = ss; break; } } if (scope == null) { scope = scopeMapper.execute(new FindByIdRequest("StreamScope", ssIdToInsert)); bookmarks.add(scope); personMapper.flush(); } return scope; } }
InsertStreamBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { Long ssIdToInsert = (Long) inActionContext.getParams(); Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); List<StreamScope> bookmarks = person.getBookmarks(); StreamScope scope = null; for (StreamScope ss : bookmarks) { if (ss.getId() == ssIdToInsert) { scope = ss; break; } } if (scope == null) { scope = scopeMapper.execute(new FindByIdRequest("StreamScope", ssIdToInsert)); bookmarks.add(scope); personMapper.flush(); } return scope; } InsertStreamBookmarkExecution(final FindByIdMapper<Person> inPersonMapper,
            final FindByIdMapper<StreamScope> inScopeMapper); }
InsertStreamBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { Long ssIdToInsert = (Long) inActionContext.getParams(); Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); List<StreamScope> bookmarks = person.getBookmarks(); StreamScope scope = null; for (StreamScope ss : bookmarks) { if (ss.getId() == ssIdToInsert) { scope = ss; break; } } if (scope == null) { scope = scopeMapper.execute(new FindByIdRequest("StreamScope", ssIdToInsert)); bookmarks.add(scope); personMapper.flush(); } return scope; } InsertStreamBookmarkExecution(final FindByIdMapper<Person> inPersonMapper,
            final FindByIdMapper<StreamScope> inScopeMapper); Serializable execute(final PrincipalActionContext inActionContext); }
InsertStreamBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException { Long ssIdToInsert = (Long) inActionContext.getParams(); Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); List<StreamScope> bookmarks = person.getBookmarks(); StreamScope scope = null; for (StreamScope ss : bookmarks) { if (ss.getId() == ssIdToInsert) { scope = ss; break; } } if (scope == null) { scope = scopeMapper.execute(new FindByIdRequest("StreamScope", ssIdToInsert)); bookmarks.add(scope); personMapper.flush(); } return scope; } InsertStreamBookmarkExecution(final FindByIdMapper<Person> inPersonMapper,
            final FindByIdMapper<StreamScope> inScopeMapper); Serializable execute(final PrincipalActionContext inActionContext);  }