@Test public void performActionWithGoodParams() throws Exception { final Gadget expected = context.mock(Gadget.class); context.checking(new Expectations() { { allowing(principalMock).getId(); will(returnValue(1L)); allowing(deleteCacheKeysMapper).execute(with(any(Set.class))); oneOf(gadgetMapper).findById(GADGET_ID1); will(returnValue(expected)); oneOf(expected).setMinimized(true); oneOf(expected).setMaximized(false); oneOf(gadgetMapper).flush(); } }); SetGadgetStateRequest currentRequest = new SetGadgetStateRequest(GADGET_ID1, State.MINIMIZED); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, principalMock); Gadget actual = sut.execute(currentContext); assertEquals("Did not return the right Tab", actual, expected); }
@Override public Gadget execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetGadgetStateRequest currentRequest = (SetGadgetStateRequest) inActionContext.getParams(); if (logger.isDebugEnabled()) { logger.debug("Calling Minimize on Gadget: " + currentRequest.getGadgetId() + ". Setting minimize to: " + currentRequest.isMinimized()); } Gadget gadget = gadgetMapper.findById(currentRequest.getGadgetId()); if (null == gadget) { throw new ExecutionException("Failed to set minimized state for gadget. Gadget id " + currentRequest.getGadgetId() + " not found"); } gadget.setMinimized(currentRequest.isMinimized()); gadget.setMaximized(currentRequest.isMaximized()); gadgetMapper.flush(); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); return gadget; }
SetGadgetStateExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Gadget execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetGadgetStateRequest currentRequest = (SetGadgetStateRequest) inActionContext.getParams(); if (logger.isDebugEnabled()) { logger.debug("Calling Minimize on Gadget: " + currentRequest.getGadgetId() + ". Setting minimize to: " + currentRequest.isMinimized()); } Gadget gadget = gadgetMapper.findById(currentRequest.getGadgetId()); if (null == gadget) { throw new ExecutionException("Failed to set minimized state for gadget. Gadget id " + currentRequest.getGadgetId() + " not found"); } gadget.setMinimized(currentRequest.isMinimized()); gadget.setMaximized(currentRequest.isMaximized()); gadgetMapper.flush(); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); return gadget; } }
SetGadgetStateExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Gadget execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetGadgetStateRequest currentRequest = (SetGadgetStateRequest) inActionContext.getParams(); if (logger.isDebugEnabled()) { logger.debug("Calling Minimize on Gadget: " + currentRequest.getGadgetId() + ". Setting minimize to: " + currentRequest.isMinimized()); } Gadget gadget = gadgetMapper.findById(currentRequest.getGadgetId()); if (null == gadget) { throw new ExecutionException("Failed to set minimized state for gadget. Gadget id " + currentRequest.getGadgetId() + " not found"); } gadget.setMinimized(currentRequest.isMinimized()); gadget.setMaximized(currentRequest.isMaximized()); gadgetMapper.flush(); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); return gadget; } SetGadgetStateExecution(final GadgetMapper inGadgetMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); }
SetGadgetStateExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Gadget execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetGadgetStateRequest currentRequest = (SetGadgetStateRequest) inActionContext.getParams(); if (logger.isDebugEnabled()) { logger.debug("Calling Minimize on Gadget: " + currentRequest.getGadgetId() + ". Setting minimize to: " + currentRequest.isMinimized()); } Gadget gadget = gadgetMapper.findById(currentRequest.getGadgetId()); if (null == gadget) { throw new ExecutionException("Failed to set minimized state for gadget. Gadget id " + currentRequest.getGadgetId() + " not found"); } gadget.setMinimized(currentRequest.isMinimized()); gadget.setMaximized(currentRequest.isMaximized()); gadgetMapper.flush(); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); return gadget; } SetGadgetStateExecution(final GadgetMapper inGadgetMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @Override Gadget execute(final PrincipalActionContext inActionContext); }
SetGadgetStateExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Gadget execute(final PrincipalActionContext inActionContext) throws ExecutionException { SetGadgetStateRequest currentRequest = (SetGadgetStateRequest) inActionContext.getParams(); if (logger.isDebugEnabled()) { logger.debug("Calling Minimize on Gadget: " + currentRequest.getGadgetId() + ". Setting minimize to: " + currentRequest.isMinimized()); } Gadget gadget = gadgetMapper.findById(currentRequest.getGadgetId()); if (null == gadget) { throw new ExecutionException("Failed to set minimized state for gadget. Gadget id " + currentRequest.getGadgetId() + " not found"); } gadget.setMinimized(currentRequest.isMinimized()); gadget.setMaximized(currentRequest.isMaximized()); gadgetMapper.flush(); deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + inActionContext.getPrincipal().getId())); return gadget; } SetGadgetStateExecution(final GadgetMapper inGadgetMapper,
            final DomainMapper<Set<String>, Boolean> inDeleteKeysMapper); @Override Gadget execute(final PrincipalActionContext inActionContext);  }