@Test public void performActionWithNullParameter() throws Exception { final String username = "ntid1234"; context.checking(new Expectations() { { allowing(actionContext).getParams(); will(returnValue(null)); allowing(actionContext).getPrincipal(); will(returnValue(actionContextPrincipal)); allowing(actionContextPrincipal).getAccountId(); will(returnValue(username)); oneOf(mapper).findByAccountId(username); will(returnValue(testPerson)); oneOf(testPerson).getTabs(TabGroupType.START); } }); sut.execute(actionContext); context.assertIsSatisfied(); }
@Override public Person execute(final PrincipalActionContext inActionContext) { Person result = null; String identifierParam = (String) inActionContext.getParams(); if (identifierParam == null) { result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId()); if (result != null) { for (Tab tab : result.getTabs(TabGroupType.START)) { for (Gadget gadget : tab.getGadgets()) { gadget.getGadgetDefinition(); } } } } else { result = mapper.findByAccountId(identifierParam); if (result != null && result.getBackground() != null) { result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size(); } } return result; }
GetPersonExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Person execute(final PrincipalActionContext inActionContext) { Person result = null; String identifierParam = (String) inActionContext.getParams(); if (identifierParam == null) { result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId()); if (result != null) { for (Tab tab : result.getTabs(TabGroupType.START)) { for (Gadget gadget : tab.getGadgets()) { gadget.getGadgetDefinition(); } } } } else { result = mapper.findByAccountId(identifierParam); if (result != null && result.getBackground() != null) { result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size(); } } return result; } }
GetPersonExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Person execute(final PrincipalActionContext inActionContext) { Person result = null; String identifierParam = (String) inActionContext.getParams(); if (identifierParam == null) { result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId()); if (result != null) { for (Tab tab : result.getTabs(TabGroupType.START)) { for (Gadget gadget : tab.getGadgets()) { gadget.getGadgetDefinition(); } } } } else { result = mapper.findByAccountId(identifierParam); if (result != null && result.getBackground() != null) { result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size(); } } return result; } GetPersonExecution(final PersonMapper inMapper); }
GetPersonExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Person execute(final PrincipalActionContext inActionContext) { Person result = null; String identifierParam = (String) inActionContext.getParams(); if (identifierParam == null) { result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId()); if (result != null) { for (Tab tab : result.getTabs(TabGroupType.START)) { for (Gadget gadget : tab.getGadgets()) { gadget.getGadgetDefinition(); } } } } else { result = mapper.findByAccountId(identifierParam); if (result != null && result.getBackground() != null) { result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size(); } } return result; } GetPersonExecution(final PersonMapper inMapper); @Override Person execute(final PrincipalActionContext inActionContext); }
GetPersonExecution implements ExecutionStrategy<PrincipalActionContext> { @Override public Person execute(final PrincipalActionContext inActionContext) { Person result = null; String identifierParam = (String) inActionContext.getParams(); if (identifierParam == null) { result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId()); if (result != null) { for (Tab tab : result.getTabs(TabGroupType.START)) { for (Gadget gadget : tab.getGadgets()) { gadget.getGadgetDefinition(); } } } } else { result = mapper.findByAccountId(identifierParam); if (result != null && result.getBackground() != null) { result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size(); } } return result; } GetPersonExecution(final PersonMapper inMapper); @Override Person execute(final PrincipalActionContext inActionContext);  }