@Test public final void testExecuteWithFullyLoadingNullSupportStream() { PersonModelView admin = new PersonModelView(); final List<PersonModelView> adminsList = new ArrayList<PersonModelView>(); adminsList.add(admin); final Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.add(admin); final List<MembershipCriteriaDTO> mcdtos = new ArrayList<MembershipCriteriaDTO>(Arrays .asList(new MembershipCriteriaDTO(5L, "foo", null, null, null, null))); final PagedSet<GalleryTabTemplateDTO> gtts = new PagedSet<GalleryTabTemplateDTO>(0, 50, 0, new ArrayList<GalleryTabTemplateDTO>(0)); final PagedSet<Theme> themes = new PagedSet<Theme>(0, 50, 0, new ArrayList<Theme>(0)); final List<ThemeDTO> themeDTOs = new ArrayList<ThemeDTO>(0); context.checking(new Expectations() { { oneOf(systemSettingDAO).execute(null); will(returnValue(systemSettings)); oneOf(systemSettings).setSystemAdministrators(with(IsEqualInternally.equalInternally(adminsSet))); allowing(systemSettings).getSystemAdministrators(); will(returnValue(adminsSet)); allowing(actionContext).getParams(); will(returnValue(new Boolean(true))); oneOf(systemAdminsMapper).execute(null); will(returnValue(adminsList)); oneOf(membershipCriteriaDAO).execute(null); will(returnValue(mcdtos)); oneOf(systemSettings).setMembershipCriteria((with(IsEqualInternally.equalInternally(mcdtos)))); allowing(systemSettings).getMembershipCriteria(); will(returnValue(mcdtos)); oneOf(galleryTabTemplateDAO).findSortedByRecent(0, maxGalleryItems); will(returnValue(gtts)); oneOf(systemSettings).setGalleryTabTemplates( (with(IsEqualInternally.equalInternally(gtts.getPagedSet())))); allowing(systemSettings).getMembershipCriteria(); will(returnValue(gtts)); allowing(systemSettings).getSupportStreamGroupShortName(); will(returnValue(null)); oneOf(themeDAO).findSortedByRecent(0, maxGalleryItems); will(returnValue(themes)); oneOf(themeTransformer).transform(with(IsEqualInternally.equalInternally(themes.getPagedSet()))); will(returnValue(themeDTOs)); oneOf(systemSettings).setThemes(themeDTOs); allowing(systemSettings).getMembershipCriteria(); will(returnValue(themes)); } }); assertEquals(systemSettings, sut.execute(actionContext)); assertEquals(1, systemSettings.getSystemAdministrators().size()); assertTrue(systemSettings.getSystemAdministrators().contains(admin)); assertEquals("foo", systemSettings.getMembershipCriteria().get(0).getCriteria()); context.assertIsSatisfied(); }
@Override public SystemSettings execute(final ActionContext inActionContext) { SystemSettings settings = systemSettingsDAO.execute(null); if (settings.getSupportStreamGroupShortName() != null && settings.getSupportStreamGroupShortName().length() > 0) { log.debug("looking for group " + settings.getSupportStreamGroupShortName()); List<DomainGroupModelView> groups = groupByShortNameMapper.execute(Collections.singletonList(settings .getSupportStreamGroupShortName())); if (groups.size() == 1) { log.debug("setting group website " + groups.get(0).getUrl()); settings.setSupportStreamWebsite(groups.get(0).getUrl()); } } if ((inActionContext.getParams() instanceof Boolean) && (Boolean) inActionContext.getParams()) { log.debug("User wants fully populated system settings - fetch admins and membership criteria."); List<PersonModelView> adminsList = systemAdminsMapper.execute(null); log.debug("Found system admins: " + adminsList); Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.addAll(adminsList); settings.setSystemAdministrators(adminsSet); settings.setMembershipCriteria(membershipCriteriaDAO.execute(null)); settings.setGalleryTabTemplates(galleryTabTemplateDAO.findSortedByRecent(0, maxGalleryItems).getPagedSet()); settings.setThemes(themeTransformer.transform(themeDAO.findSortedByRecent(0, maxGalleryItems) .getPagedSet())); } return settings; }
GetSystemSettingsExecution implements ExecutionStrategy<ActionContext> { @Override public SystemSettings execute(final ActionContext inActionContext) { SystemSettings settings = systemSettingsDAO.execute(null); if (settings.getSupportStreamGroupShortName() != null && settings.getSupportStreamGroupShortName().length() > 0) { log.debug("looking for group " + settings.getSupportStreamGroupShortName()); List<DomainGroupModelView> groups = groupByShortNameMapper.execute(Collections.singletonList(settings .getSupportStreamGroupShortName())); if (groups.size() == 1) { log.debug("setting group website " + groups.get(0).getUrl()); settings.setSupportStreamWebsite(groups.get(0).getUrl()); } } if ((inActionContext.getParams() instanceof Boolean) && (Boolean) inActionContext.getParams()) { log.debug("User wants fully populated system settings - fetch admins and membership criteria."); List<PersonModelView> adminsList = systemAdminsMapper.execute(null); log.debug("Found system admins: " + adminsList); Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.addAll(adminsList); settings.setSystemAdministrators(adminsSet); settings.setMembershipCriteria(membershipCriteriaDAO.execute(null)); settings.setGalleryTabTemplates(galleryTabTemplateDAO.findSortedByRecent(0, maxGalleryItems).getPagedSet()); settings.setThemes(themeTransformer.transform(themeDAO.findSortedByRecent(0, maxGalleryItems) .getPagedSet())); } return settings; } }
GetSystemSettingsExecution implements ExecutionStrategy<ActionContext> { @Override public SystemSettings execute(final ActionContext inActionContext) { SystemSettings settings = systemSettingsDAO.execute(null); if (settings.getSupportStreamGroupShortName() != null && settings.getSupportStreamGroupShortName().length() > 0) { log.debug("looking for group " + settings.getSupportStreamGroupShortName()); List<DomainGroupModelView> groups = groupByShortNameMapper.execute(Collections.singletonList(settings .getSupportStreamGroupShortName())); if (groups.size() == 1) { log.debug("setting group website " + groups.get(0).getUrl()); settings.setSupportStreamWebsite(groups.get(0).getUrl()); } } if ((inActionContext.getParams() instanceof Boolean) && (Boolean) inActionContext.getParams()) { log.debug("User wants fully populated system settings - fetch admins and membership criteria."); List<PersonModelView> adminsList = systemAdminsMapper.execute(null); log.debug("Found system admins: " + adminsList); Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.addAll(adminsList); settings.setSystemAdministrators(adminsSet); settings.setMembershipCriteria(membershipCriteriaDAO.execute(null)); settings.setGalleryTabTemplates(galleryTabTemplateDAO.findSortedByRecent(0, maxGalleryItems).getPagedSet()); settings.setThemes(themeTransformer.transform(themeDAO.findSortedByRecent(0, maxGalleryItems) .getPagedSet())); } return settings; } GetSystemSettingsExecution(
            final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO,
            final DomainMapper<Serializable, List<PersonModelView>> inSystemAdminsMapper,
            final DomainMapper<MapperRequest, List<MembershipCriteriaDTO>> inMembershipCriteriaDAO,
            final GalleryItemMapper<GalleryTabTemplateDTO> inGalleryTabTemplateDAO,
            final GalleryItemMapper<Theme> inThemeDAO, //
            final Transformer<List<Theme>, List<ThemeDTO>> inThemeTransformer,
            final GetDomainGroupsByShortNames inGroupByShortNameMapper); }
GetSystemSettingsExecution implements ExecutionStrategy<ActionContext> { @Override public SystemSettings execute(final ActionContext inActionContext) { SystemSettings settings = systemSettingsDAO.execute(null); if (settings.getSupportStreamGroupShortName() != null && settings.getSupportStreamGroupShortName().length() > 0) { log.debug("looking for group " + settings.getSupportStreamGroupShortName()); List<DomainGroupModelView> groups = groupByShortNameMapper.execute(Collections.singletonList(settings .getSupportStreamGroupShortName())); if (groups.size() == 1) { log.debug("setting group website " + groups.get(0).getUrl()); settings.setSupportStreamWebsite(groups.get(0).getUrl()); } } if ((inActionContext.getParams() instanceof Boolean) && (Boolean) inActionContext.getParams()) { log.debug("User wants fully populated system settings - fetch admins and membership criteria."); List<PersonModelView> adminsList = systemAdminsMapper.execute(null); log.debug("Found system admins: " + adminsList); Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.addAll(adminsList); settings.setSystemAdministrators(adminsSet); settings.setMembershipCriteria(membershipCriteriaDAO.execute(null)); settings.setGalleryTabTemplates(galleryTabTemplateDAO.findSortedByRecent(0, maxGalleryItems).getPagedSet()); settings.setThemes(themeTransformer.transform(themeDAO.findSortedByRecent(0, maxGalleryItems) .getPagedSet())); } return settings; } GetSystemSettingsExecution(
            final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO,
            final DomainMapper<Serializable, List<PersonModelView>> inSystemAdminsMapper,
            final DomainMapper<MapperRequest, List<MembershipCriteriaDTO>> inMembershipCriteriaDAO,
            final GalleryItemMapper<GalleryTabTemplateDTO> inGalleryTabTemplateDAO,
            final GalleryItemMapper<Theme> inThemeDAO, //
            final Transformer<List<Theme>, List<ThemeDTO>> inThemeTransformer,
            final GetDomainGroupsByShortNames inGroupByShortNameMapper); @Override SystemSettings execute(final ActionContext inActionContext); }
GetSystemSettingsExecution implements ExecutionStrategy<ActionContext> { @Override public SystemSettings execute(final ActionContext inActionContext) { SystemSettings settings = systemSettingsDAO.execute(null); if (settings.getSupportStreamGroupShortName() != null && settings.getSupportStreamGroupShortName().length() > 0) { log.debug("looking for group " + settings.getSupportStreamGroupShortName()); List<DomainGroupModelView> groups = groupByShortNameMapper.execute(Collections.singletonList(settings .getSupportStreamGroupShortName())); if (groups.size() == 1) { log.debug("setting group website " + groups.get(0).getUrl()); settings.setSupportStreamWebsite(groups.get(0).getUrl()); } } if ((inActionContext.getParams() instanceof Boolean) && (Boolean) inActionContext.getParams()) { log.debug("User wants fully populated system settings - fetch admins and membership criteria."); List<PersonModelView> adminsList = systemAdminsMapper.execute(null); log.debug("Found system admins: " + adminsList); Set<PersonModelView> adminsSet = new HashSet<PersonModelView>(); adminsSet.addAll(adminsList); settings.setSystemAdministrators(adminsSet); settings.setMembershipCriteria(membershipCriteriaDAO.execute(null)); settings.setGalleryTabTemplates(galleryTabTemplateDAO.findSortedByRecent(0, maxGalleryItems).getPagedSet()); settings.setThemes(themeTransformer.transform(themeDAO.findSortedByRecent(0, maxGalleryItems) .getPagedSet())); } return settings; } GetSystemSettingsExecution(
            final DomainMapper<MapperRequest, SystemSettings> inSystemSettingsDAO,
            final DomainMapper<Serializable, List<PersonModelView>> inSystemAdminsMapper,
            final DomainMapper<MapperRequest, List<MembershipCriteriaDTO>> inMembershipCriteriaDAO,
            final GalleryItemMapper<GalleryTabTemplateDTO> inGalleryTabTemplateDAO,
            final GalleryItemMapper<Theme> inThemeDAO, //
            final Transformer<List<Theme>, List<ThemeDTO>> inThemeTransformer,
            final GetDomainGroupsByShortNames inGroupByShortNameMapper); @Override SystemSettings execute(final ActionContext inActionContext);  }