@Test(expected = ExecutionException.class) public void performActionWithBadGadgetId() throws Exception { final Long noSuchGadgetId = 99L; context.checking(new Expectations() { { oneOf(gadgetMapper).findById(noSuchGadgetId); will(returnValue(null)); } }); SetGadgetStateRequest currentRequest = new SetGadgetStateRequest(noSuchGadgetId, State.MINIMIZED); ServiceActionContext currentContext = new ServiceActionContext(currentRequest, principalMock); sut.execute(currentContext); }
@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);  }