@Test public final void executeTest() { final Long personId = 42L; final Long streamId = 1L; context.checking(new Expectations() { { oneOf(actionContext).getPrincipal(); will(returnValue(principal)); oneOf(principal).getId(); will(returnValue(personId)); oneOf(actionContext).getParams(); will(returnValue(streamId)); } }); Person p = findByIdMapper.execute(new FindByIdRequest("Person", personId)); Assert.assertEquals(2, p.getBookmarks().size()); sut.execute(actionContext); getEntityManager().clear(); p = findByIdMapper.execute(new FindByIdRequest("Person", personId)); Assert.assertEquals(1, p.getBookmarks().size()); Assert.assertEquals(2L, p.getBookmarks().get(0).getId()); context.assertIsSatisfied(); }
@Override public Serializable execute(final PrincipalActionContext inActionContext) { Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); Long ssIdToRemove = (Long) inActionContext.getParams(); List<StreamScope> bookmarks = person.getBookmarks(); log.debug("Attempting to delete bookmark with id: " + ssIdToRemove); for (StreamScope ss : bookmarks) { log.debug("Examinging SS with id: " + ss.getId()); if (ss.getId() == ssIdToRemove) { log.debug("Match found!"); bookmarks.remove(ss); personMapper.flush(); break; } } return Boolean.TRUE; }
DeleteCurrentUserBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); Long ssIdToRemove = (Long) inActionContext.getParams(); List<StreamScope> bookmarks = person.getBookmarks(); log.debug("Attempting to delete bookmark with id: " + ssIdToRemove); for (StreamScope ss : bookmarks) { log.debug("Examinging SS with id: " + ss.getId()); if (ss.getId() == ssIdToRemove) { log.debug("Match found!"); bookmarks.remove(ss); personMapper.flush(); break; } } return Boolean.TRUE; } }
DeleteCurrentUserBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); Long ssIdToRemove = (Long) inActionContext.getParams(); List<StreamScope> bookmarks = person.getBookmarks(); log.debug("Attempting to delete bookmark with id: " + ssIdToRemove); for (StreamScope ss : bookmarks) { log.debug("Examinging SS with id: " + ss.getId()); if (ss.getId() == ssIdToRemove) { log.debug("Match found!"); bookmarks.remove(ss); personMapper.flush(); break; } } return Boolean.TRUE; } DeleteCurrentUserBookmarkExecution(final FindByIdMapper<Person> inPersonMapper); }
DeleteCurrentUserBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); Long ssIdToRemove = (Long) inActionContext.getParams(); List<StreamScope> bookmarks = person.getBookmarks(); log.debug("Attempting to delete bookmark with id: " + ssIdToRemove); for (StreamScope ss : bookmarks) { log.debug("Examinging SS with id: " + ss.getId()); if (ss.getId() == ssIdToRemove) { log.debug("Match found!"); bookmarks.remove(ss); personMapper.flush(); break; } } return Boolean.TRUE; } DeleteCurrentUserBookmarkExecution(final FindByIdMapper<Person> inPersonMapper); @Override Serializable execute(final PrincipalActionContext inActionContext); }
DeleteCurrentUserBookmarkExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Serializable execute(final PrincipalActionContext inActionContext) { Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId())); Long ssIdToRemove = (Long) inActionContext.getParams(); List<StreamScope> bookmarks = person.getBookmarks(); log.debug("Attempting to delete bookmark with id: " + ssIdToRemove); for (StreamScope ss : bookmarks) { log.debug("Examinging SS with id: " + ss.getId()); if (ss.getId() == ssIdToRemove) { log.debug("Match found!"); bookmarks.remove(ss); personMapper.flush(); break; } } return Boolean.TRUE; } DeleteCurrentUserBookmarkExecution(final FindByIdMapper<Person> inPersonMapper); @Override Serializable execute(final PrincipalActionContext inActionContext);  }