@Test public void test() { context.checking(new Expectations() { { allowing(createRequest).getPerson(); will(returnValue(person)); allowing(person).getAccountId(); allowing(person).getProperties(); allowing(createPersonActionFactory).getCreatePersonAction(with(any(PersonMapper.class)), with(any(UpdaterStrategy.class))); will(returnValue(persistResourceExecution)); allowing(persistResourceExecution).execute(with(any(TaskHandlerActionContext.class))); will(returnValue(person)); allowing(createRequest).getSendEmail(); will(returnValue(true)); allowing(person).getEmail(); will(returnValue("eamil@email.com")); } }); TaskHandlerActionContext<ActionContext> taskHandlerActionContext = TestContextCreator .createTaskHandlerAsyncContext(createRequest); List<UserActionRequest> list = taskHandlerActionContext.getUserActionRequests(); sut.execute(taskHandlerActionContext); assertEquals(1, list.size()); context.assertIsSatisfied(); }
@Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { CreatePersonRequest createRequest = (CreatePersonRequest) inActionContext.getActionContext().getParams(); Person inPerson = createRequest.getPerson(); PersistResourceExecution<Person> persistResourceExecution = createPersonActionFactory.getCreatePersonAction( personMapper, new ReflectiveUpdater()); log.debug("Adding to database: " + inPerson.getAccountId()); Person person = (Person) new InlineExecutionStrategyExecutor().execute(persistResourceExecution, inPerson.getProperties(), inActionContext); log.info("Added to database: " + inPerson.getAccountId()); if (createRequest.getSendEmail() && sendWelcomeEmailAction != null && !sendWelcomeEmailAction.isEmpty()) { inActionContext.getUserActionRequests().add( new UserActionRequest(sendWelcomeEmailAction, null, new SendWelcomeEmailRequest( inPerson.getEmail(), inPerson.getAccountId()))); } return person; }
CreatePersonExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { CreatePersonRequest createRequest = (CreatePersonRequest) inActionContext.getActionContext().getParams(); Person inPerson = createRequest.getPerson(); PersistResourceExecution<Person> persistResourceExecution = createPersonActionFactory.getCreatePersonAction( personMapper, new ReflectiveUpdater()); log.debug("Adding to database: " + inPerson.getAccountId()); Person person = (Person) new InlineExecutionStrategyExecutor().execute(persistResourceExecution, inPerson.getProperties(), inActionContext); log.info("Added to database: " + inPerson.getAccountId()); if (createRequest.getSendEmail() && sendWelcomeEmailAction != null && !sendWelcomeEmailAction.isEmpty()) { inActionContext.getUserActionRequests().add( new UserActionRequest(sendWelcomeEmailAction, null, new SendWelcomeEmailRequest( inPerson.getEmail(), inPerson.getAccountId()))); } return person; } }
CreatePersonExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { CreatePersonRequest createRequest = (CreatePersonRequest) inActionContext.getActionContext().getParams(); Person inPerson = createRequest.getPerson(); PersistResourceExecution<Person> persistResourceExecution = createPersonActionFactory.getCreatePersonAction( personMapper, new ReflectiveUpdater()); log.debug("Adding to database: " + inPerson.getAccountId()); Person person = (Person) new InlineExecutionStrategyExecutor().execute(persistResourceExecution, inPerson.getProperties(), inActionContext); log.info("Added to database: " + inPerson.getAccountId()); if (createRequest.getSendEmail() && sendWelcomeEmailAction != null && !sendWelcomeEmailAction.isEmpty()) { inActionContext.getUserActionRequests().add( new UserActionRequest(sendWelcomeEmailAction, null, new SendWelcomeEmailRequest( inPerson.getEmail(), inPerson.getAccountId()))); } return person; } CreatePersonExecution(final CreatePersonActionFactory inCreatePersonActionFactory,
            final PersonMapper inPersonMapper, final String inSendWelcomeEmailAction); }
CreatePersonExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { CreatePersonRequest createRequest = (CreatePersonRequest) inActionContext.getActionContext().getParams(); Person inPerson = createRequest.getPerson(); PersistResourceExecution<Person> persistResourceExecution = createPersonActionFactory.getCreatePersonAction( personMapper, new ReflectiveUpdater()); log.debug("Adding to database: " + inPerson.getAccountId()); Person person = (Person) new InlineExecutionStrategyExecutor().execute(persistResourceExecution, inPerson.getProperties(), inActionContext); log.info("Added to database: " + inPerson.getAccountId()); if (createRequest.getSendEmail() && sendWelcomeEmailAction != null && !sendWelcomeEmailAction.isEmpty()) { inActionContext.getUserActionRequests().add( new UserActionRequest(sendWelcomeEmailAction, null, new SendWelcomeEmailRequest( inPerson.getEmail(), inPerson.getAccountId()))); } return person; } CreatePersonExecution(final CreatePersonActionFactory inCreatePersonActionFactory,
            final PersonMapper inPersonMapper, final String inSendWelcomeEmailAction); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext); }
CreatePersonExecution implements TaskHandlerExecutionStrategy<ActionContext> { @Override public Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext) { CreatePersonRequest createRequest = (CreatePersonRequest) inActionContext.getActionContext().getParams(); Person inPerson = createRequest.getPerson(); PersistResourceExecution<Person> persistResourceExecution = createPersonActionFactory.getCreatePersonAction( personMapper, new ReflectiveUpdater()); log.debug("Adding to database: " + inPerson.getAccountId()); Person person = (Person) new InlineExecutionStrategyExecutor().execute(persistResourceExecution, inPerson.getProperties(), inActionContext); log.info("Added to database: " + inPerson.getAccountId()); if (createRequest.getSendEmail() && sendWelcomeEmailAction != null && !sendWelcomeEmailAction.isEmpty()) { inActionContext.getUserActionRequests().add( new UserActionRequest(sendWelcomeEmailAction, null, new SendWelcomeEmailRequest( inPerson.getEmail(), inPerson.getAccountId()))); } return person; } CreatePersonExecution(final CreatePersonActionFactory inCreatePersonActionFactory,
            final PersonMapper inPersonMapper, final String inSendWelcomeEmailAction); @Override Serializable execute(final TaskHandlerActionContext<ActionContext> inActionContext);  }