@Test public final void testValidateParamsWithGoodUrlParams() { final PrincipalActionContext serviceContext = buildServerActionContext(testTheme.getUrl()); context.checking(new Expectations() { { oneOf(themeMapper).findByUrl(testTheme.getUrl()); will(returnValue(testTheme)); } }); sut.validate(serviceContext); assertSame(testTheme, serviceContext.getState().get("THEME")); }
@Override public void validate(final PrincipalActionContext inActionContext) { String themeId = (String) inActionContext.getParams(); Theme theme; if (themeId.startsWith("{") && themeId.substring(themeId.length() - 1).equals("}")) { theme = themeMapper.findByUUID(themeId.substring(1, themeId.length() - 1)); } else { theme = themeMapper.findByUrl(themeId); } if (null == theme) { throw new ValidationException("Unable to instantiate theme."); } inActionContext.getState().put("THEME", theme); }
ThemeIdValidation implements ValidationStrategy<PrincipalActionContext> { @Override public void validate(final PrincipalActionContext inActionContext) { String themeId = (String) inActionContext.getParams(); Theme theme; if (themeId.startsWith("{") && themeId.substring(themeId.length() - 1).equals("}")) { theme = themeMapper.findByUUID(themeId.substring(1, themeId.length() - 1)); } else { theme = themeMapper.findByUrl(themeId); } if (null == theme) { throw new ValidationException("Unable to instantiate theme."); } inActionContext.getState().put("THEME", theme); } }
ThemeIdValidation implements ValidationStrategy<PrincipalActionContext> { @Override public void validate(final PrincipalActionContext inActionContext) { String themeId = (String) inActionContext.getParams(); Theme theme; if (themeId.startsWith("{") && themeId.substring(themeId.length() - 1).equals("}")) { theme = themeMapper.findByUUID(themeId.substring(1, themeId.length() - 1)); } else { theme = themeMapper.findByUrl(themeId); } if (null == theme) { throw new ValidationException("Unable to instantiate theme."); } inActionContext.getState().put("THEME", theme); } ThemeIdValidation(final ThemeMapper inThemeMapper); }
ThemeIdValidation implements ValidationStrategy<PrincipalActionContext> { @Override public void validate(final PrincipalActionContext inActionContext) { String themeId = (String) inActionContext.getParams(); Theme theme; if (themeId.startsWith("{") && themeId.substring(themeId.length() - 1).equals("}")) { theme = themeMapper.findByUUID(themeId.substring(1, themeId.length() - 1)); } else { theme = themeMapper.findByUrl(themeId); } if (null == theme) { throw new ValidationException("Unable to instantiate theme."); } inActionContext.getState().put("THEME", theme); } ThemeIdValidation(final ThemeMapper inThemeMapper); @Override void validate(final PrincipalActionContext inActionContext); }
ThemeIdValidation implements ValidationStrategy<PrincipalActionContext> { @Override public void validate(final PrincipalActionContext inActionContext) { String themeId = (String) inActionContext.getParams(); Theme theme; if (themeId.startsWith("{") && themeId.substring(themeId.length() - 1).equals("}")) { theme = themeMapper.findByUUID(themeId.substring(1, themeId.length() - 1)); } else { theme = themeMapper.findByUrl(themeId); } if (null == theme) { throw new ValidationException("Unable to instantiate theme."); } inActionContext.getState().put("THEME", theme); } ThemeIdValidation(final ThemeMapper inThemeMapper); @Override void validate(final PrincipalActionContext inActionContext);  }