@Test public void testExecute_WithActiveUser_secondState() throws Exception { final Date activationDate = new Date(); User user = TestUtil.createUser(); user.setActiveted(activationDate); Site parentSite = TestUtil.createSite(); DraftChildSiteRegistration registration = TestUtil.createChildSiteRegistration(parentSite); ChildSiteSettings settings = TestUtil.createChildSiteSettings(registration, parentSite); settings.setUserId(user.getUserId()); settings.setConfirmCode("confirm"); settings.setCreatedDate(new Date()); settings.setAccessLevel(SiteAccessLevel.ADMINISTRATOR); action.setSettingsId(settings.getChildSiteSettingsId()); action.setConfirmCode("confirm"); ForwardResolution resolutionMock = (ForwardResolution) action.show(); Assert.assertNotNull(new UsersManager().getLoginedUser()); Assert.assertEquals(user, new UsersManager().getLoginedUser()); Assert.assertEquals( "/account/registration/childSiteRigistrationConfirmationSecondState.jsp", resolutionMock.getPath()); }
@Test public void testExecute_WithActiveUserAndCreatedChildSite() throws Exception { final Date activationDate = new Date(); User user = TestUtil.createUser(); user.setActiveted(activationDate); Site parentSite = TestUtil.createSite(); DraftChildSiteRegistration registration = TestUtil.createChildSiteRegistration(parentSite); ChildSiteSettings settings = TestUtil.createChildSiteSettings(registration, parentSite); Site childSite = TestUtil.createSite(); settings.setSite(childSite); settings.setUserId(user.getUserId()); settings.setConfirmCode("confirm"); settings.setCreatedDate(new Date()); settings.setAccessLevel(SiteAccessLevel.ADMINISTRATOR); action.setSettingsId(settings.getChildSiteSettingsId()); action.setConfirmCode("confirm"); ResolutionMock resolutionMock = (ResolutionMock) action.show(); Assert.assertEquals(SiteEditPageAction.class, resolutionMock.getRedirectByAction()); Assert.assertEquals("siteId", resolutionMock.getRedirectByActionParameters()[0].getName()); Assert.assertEquals( childSite.getSiteId(), resolutionMock.getRedirectByActionParameters()[0].getValue()); }
@Test public void testExecute_WithFirstState() throws Exception { ServiceLocator.getConfigStorage().get().setUserSitesUrl("web-deva.com"); User user = TestUtil.createUser(); user.setActiveted(null); Site parentSite = TestUtil.createSite(); DraftChildSiteRegistration registration = TestUtil.createChildSiteRegistration(parentSite); ChildSiteSettings settings = TestUtil.createChildSiteSettings(registration, parentSite); settings.setCreatedDate(new Date()); settings.setUserId(user.getUserId()); settings.setConfirmCode("confirm"); settings.setAccessLevel(SiteAccessLevel.ADMINISTRATOR); FilledForm filledForm = TestUtil.createFilledForm(registration.getFormId()); FilledFormItem filledFormItemDomainName = TestUtil.createFilledFormItem(FormItemName.YOUR_OWN_DOMAIN_NAME); List<String> values = Arrays.asList("domainName"); filledFormItemDomainName.setValues(values); FilledFormItem filledFormItemSiteName = TestUtil.createFilledFormItem(FormItemName.YOUR_PAGE_SITE_NAME); List<String> siteNameValues = Arrays.asList("siteName"); filledFormItemSiteName.setValues(siteNameValues); filledForm.setFilledFormItems(Arrays.asList(filledFormItemDomainName, filledFormItemSiteName)); settings.setFilledFormId(filledForm.getFilledFormId()); action.setSettingsId(settings.getChildSiteSettingsId()); action.setConfirmCode("confirm"); DraftChildSiteRegistration childSiteRegistration = TestUtil.createChildSiteRegistration("name", "comment"); Site blueprint = TestUtil.createBlueprint(); childSiteRegistration.setBlueprintsId(Arrays.asList(blueprint.getSiteId())); settings.setRequiredToUseSiteBlueprint(true); final SitePaymentSettings sitePaymentSettings = new SitePaymentSettings(); sitePaymentSettings.setSiteStatus(SiteStatus.ACTIVE); settings.setSitePaymentSettings(sitePaymentSettings); settings.setChildSiteRegistration(childSiteRegistration); Assert.assertNull(user.getActiveted()); Assert.assertNull(new UsersManager().getLoginedUser()); Assert.assertNull(ServiceLocator.getPersistance().getSiteBySubDomain("domainname")); ForwardResolution resolutionMock = (ForwardResolution) action.show(); Assert.assertNotNull(new UsersManager().getLoginedUser()); Assert.assertEquals(user, new UsersManager().getLoginedUser()); Assert.assertEquals( "/account/registration/childSiteRigistrationConfirmationFirstState.jsp", resolutionMock.getPath()); Assert.assertNotNull(user.getActiveted()); Assert.assertNotNull(new UsersManager().getLoginedUser()); Assert.assertEquals(user, new UsersManager().getLoginedUser()); Site site = ServiceLocator.getPersistance().getSiteBySubDomain("domainname"); Assert.assertNotNull(site); Assert.assertNotNull(new UserRightManager(user).toSite(site).getSiteAccessType()); Assert.assertEquals( settings.getAccessLevel(), new UserRightManager(user).toSite(site).getSiteAccessType()); Assert.assertEquals("domainname", site.getSubDomain()); Assert.assertEquals("http://domainname.web-deva.com", action.getUrl()); Assert.assertNotNull(action.getTellFriendHtml()); Assert.assertEquals(2, site.getPages().size()); Assert.assertEquals("siteName", site.getTitle()); Assert.assertEquals(blueprint, site.getBlueprintParent()); }