@Test public void testExecute_WithSecondState() throws Exception { 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"); action.setSettingsId(settings.getChildSiteSettingsId()); action.setConfirmCode("confirm"); DraftChildSiteRegistration childSiteRegistration = TestUtil.createChildSiteRegistration("name", "comment"); childSiteRegistration.setBlueprintsId(Arrays.asList(1, 2)); settings.setRequiredToUseSiteBlueprint(true); settings.setSitePaymentSettings(new SitePaymentSettings()); settings.setChildSiteRegistration(childSiteRegistration); Assert.assertNull(user.getActiveted()); Assert.assertNull(new UsersManager().getLoginedUser()); ForwardResolution resolutionMock = (ForwardResolution) action.show(); Assert.assertNotNull(new UsersManager().getLoginedUser()); Assert.assertEquals(user, new UsersManager().getLoginedUser()); Assert.assertEquals( "/account/registration/childSiteRigistrationConfirmationSecondState.jsp", resolutionMock.getPath()); Assert.assertNotNull(user.getActiveted()); Assert.assertNotNull(new UsersManager().getLoginedUser()); Assert.assertEquals(user, new UsersManager().getLoginedUser()); Assert.assertNull(action.getTellFriendHtml()); }
@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()); }