@Test public void test() { final Sequence sequence = context.sequence("sequence-name"); context.checking(new Expectations() { { allowing(actionContext).getPrincipal(); will(returnValue(principal)); allowing(principal).getId(); will(returnValue(userId)); allowing(actionContext).getParams(); will(returnValue(gttId)); oneOf(gtt).getTabTemplate(); will(returnValue(tt)); ignoring(tt); ignoring(person); oneOf(findById).execute(with(any(FindByIdRequest.class))); will(returnValue(person)); inSequence(sequence); oneOf(findById).execute(with(any(FindByIdRequest.class))); will(returnValue(gtt)); inSequence(sequence); oneOf(deleteKeysMapper).execute(with(any(Set.class))); } }); assertTrue(sut.execute(actionContext)); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") @Override public Boolean execute(final PrincipalActionContext inActionContext) { Person currentUser = (Person) findById.execute(new FindByIdRequest("Person", inActionContext.getPrincipal() .getId())); GalleryTabTemplate gtt = (GalleryTabTemplate) findById.execute(new FindByIdRequest("GalleryTabTemplate", (Long) inActionContext.getParams())); TabTemplate newTabTemplate = new TabTemplate(gtt.getTabTemplate()); newTabTemplate.setGalleryTabTemplate(gtt); for (Gadget gadget : newTabTemplate.getGadgets()) { gadget.setOwner(currentUser); } currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate)); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId())); return true; }
AddTabFromGalleryTabTemplateIdExecution implements ExecutionStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public Boolean execute(final PrincipalActionContext inActionContext) { Person currentUser = (Person) findById.execute(new FindByIdRequest("Person", inActionContext.getPrincipal() .getId())); GalleryTabTemplate gtt = (GalleryTabTemplate) findById.execute(new FindByIdRequest("GalleryTabTemplate", (Long) inActionContext.getParams())); TabTemplate newTabTemplate = new TabTemplate(gtt.getTabTemplate()); newTabTemplate.setGalleryTabTemplate(gtt); for (Gadget gadget : newTabTemplate.getGadgets()) { gadget.setOwner(currentUser); } currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate)); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId())); return true; } }
AddTabFromGalleryTabTemplateIdExecution implements ExecutionStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public Boolean execute(final PrincipalActionContext inActionContext) { Person currentUser = (Person) findById.execute(new FindByIdRequest("Person", inActionContext.getPrincipal() .getId())); GalleryTabTemplate gtt = (GalleryTabTemplate) findById.execute(new FindByIdRequest("GalleryTabTemplate", (Long) inActionContext.getParams())); TabTemplate newTabTemplate = new TabTemplate(gtt.getTabTemplate()); newTabTemplate.setGalleryTabTemplate(gtt); for (Gadget gadget : newTabTemplate.getGadgets()) { gadget.setOwner(currentUser); } currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate)); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId())); return true; } AddTabFromGalleryTabTemplateIdExecution(final DomainMapper inFindById,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); }
AddTabFromGalleryTabTemplateIdExecution implements ExecutionStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public Boolean execute(final PrincipalActionContext inActionContext) { Person currentUser = (Person) findById.execute(new FindByIdRequest("Person", inActionContext.getPrincipal() .getId())); GalleryTabTemplate gtt = (GalleryTabTemplate) findById.execute(new FindByIdRequest("GalleryTabTemplate", (Long) inActionContext.getParams())); TabTemplate newTabTemplate = new TabTemplate(gtt.getTabTemplate()); newTabTemplate.setGalleryTabTemplate(gtt); for (Gadget gadget : newTabTemplate.getGadgets()) { gadget.setOwner(currentUser); } currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate)); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId())); return true; } AddTabFromGalleryTabTemplateIdExecution(final DomainMapper inFindById,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @SuppressWarnings("unchecked") @Override Boolean execute(final PrincipalActionContext inActionContext); }
AddTabFromGalleryTabTemplateIdExecution implements ExecutionStrategy<PrincipalActionContext> { @SuppressWarnings("unchecked") @Override public Boolean execute(final PrincipalActionContext inActionContext) { Person currentUser = (Person) findById.execute(new FindByIdRequest("Person", inActionContext.getPrincipal() .getId())); GalleryTabTemplate gtt = (GalleryTabTemplate) findById.execute(new FindByIdRequest("GalleryTabTemplate", (Long) inActionContext.getParams())); TabTemplate newTabTemplate = new TabTemplate(gtt.getTabTemplate()); newTabTemplate.setGalleryTabTemplate(gtt); for (Gadget gadget : newTabTemplate.getGadgets()) { gadget.setOwner(currentUser); } currentUser.getStartTabGroup().addTab(new Tab(newTabTemplate)); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + currentUser.getId())); return true; } AddTabFromGalleryTabTemplateIdExecution(final DomainMapper inFindById,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @SuppressWarnings("unchecked") @Override Boolean execute(final PrincipalActionContext inActionContext);  }