### Question:
AccountActivateHandler implements ContextualRequestMessageHandler<Account> { @Override public MessageBody handleRequest(Account context, PlatformMessage msg) { String curState = context.getState(); if(Account.AccountState.COMPLETE.equalsIgnoreCase(curState)) { return AccountCapability.ActivateResponse.instance(); } validateAccount(context); context.setState(Account.AccountState.COMPLETE); accountDao.save(context); if(curState == null || Account.AccountState.SIGN_UP_1.equalsIgnoreCase(curState)) { AccountStateTransitionUtils.sendAccountCreatedNotification(context.getOwner(), platformBus); } sendValueChange(context); return AccountCapability.ActivateResponse.instance(); } @Inject  AccountActivateHandler(AccountDAO accountDao, 
   		PersonDAO personDao, 
   		PlatformMessageBus platformBus,
   		PlacePopulationCacheManager populationCacheMgr); @Override String getMessageType(); @Override MessageBody handleRequest(Account context, PlatformMessage msg); final static String ERROR_INVALID_STATE; }### Answer:
@Test public void testMissingOwnerName() { Person owner = createPerson(); owner.setFirstName(null); Account account = createAccount(curAccountState); account.setOwner(owner.getId()); owner.setAccountId(account.getId()); EasyMock.expect(personDao.findById(owner.getId())).andReturn(owner).anyTimes(); replay(); try{ handler.handleRequest(account, createAccountActivateMessage(account)); if(!alwaysSucceed) { fail("should fail"); } }catch(ErrorEventException e) { assertEquals(AccountActivateHandler.ERROR_INVALID_STATE, e.getCode()); } verify(); }
@Test public void testMissingOwner() { Person owner = createPerson(); Account account = createAccount(curAccountState); account.setOwner(null); owner.setAccountId(account.getId()); replay(); try{ handler.handleRequest(account, createAccountActivateMessage(account)); if(!alwaysSucceed) { fail("should fail"); } }catch(ErrorEventException e) { assertEquals(AccountActivateHandler.ERROR_INVALID_STATE, e.getCode()); } verify(); }