com.opensymphony.xwork2.Action Java Examples

The following examples show how to use com.opensymphony.xwork2.Action. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestContentInspectionAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testInspectContent_1() throws Throwable {
	String result = this.executeInspect("ART102", true, "admin");
	assertEquals(Action.SUCCESS, result);
	ContentInspectionAction action = (ContentInspectionAction) this.getAction();
	List<ContentRecordVO> referencedContents = action.getReferencedContents();
	assertNotNull(referencedContents);
	assertEquals(1, referencedContents.size());
	
	List<ContentRecordVO> referencingContents = action.getReferencingContents();
	assertNotNull(referencingContents);
	assertEquals(0, referencingContents.size());
	
	List<IPage> referencedPages = action.getReferencedPages();
	assertNotNull(referencedPages);
	assertEquals(0, referencedPages.size());
	
	List<IPage> referencingPages = action.getReferencingPages();
	assertNotNull(referencingPages);
	assertEquals(0, referencingPages.size());
}
 
Example #2
Source File: TestWorkflowNotifierConfigAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testConfig() throws Throwable {
	String result = this.executeConfig("supervisorCoach");
	assertEquals("userNotAllowed", result);
	
	result = this.executeConfig("admin");
	assertEquals(Action.SUCCESS, result);
	WorkflowNotifierConfigAction action = (WorkflowNotifierConfigAction) this.getAction();
	NotifierConfig config = action.getConfig();
	assertFalse(config.isActive());
	assertEquals(24, config.getHoursDelay());
	assertEquals("CODE1", config.getSenderCode());
	//assertEquals("email", config.getMailAttrName());
	assertEquals("04/12/2008", action.getStartDate());
	assertEquals(16, action.getHour());
	assertEquals(8, action.getMinute());
	
	assertFalse(config.isHtml());
               assertEquals("[My Own Portal]: A content changed", config.getSubject());
               assertEquals("Hi {user},<br />these contents require your attention<br /><br />", config.getHeader());
               assertEquals("<br />Content {type} - {descr} - Status {status}<br />", config.getTemplate());
               assertEquals("<br />End (footer)", config.getFooter());
}
 
Example #3
Source File: TestLocaleStringAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureSaveNew_3() throws Throwable {
	//key with special characters
	String wrongKey = "test_&HF";
	assertNull(this._i18nManager.getLabelGroup(wrongKey));
	try {
		String result = this.executeSaveNew("admin", wrongKey, "itValue", "enValue");
		assertEquals(Action.INPUT, result);
		Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
		assertEquals(1, fieldErrors.size());
		assertNotNull(fieldErrors.get("key"));
           assertNull(this._i18nManager.getLabelGroup(wrongKey));
	} catch (Throwable t) {
		this._i18nManager.deleteLabelGroup(wrongKey);
		throw t;
	}
}
 
Example #4
Source File: AuthenticationInterceptor.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public String intercept(ActionInvocation actionInvocation)
		throws Exception {
	System.out.println("inside auth interceptor");
	Map<String, Object> sessionAttributes = actionInvocation.getInvocationContext().getSession();
	
	User user = (User) sessionAttributes.get("USER");
	
	if(user == null){
		return Action.LOGIN;
	}else{
		Action action = (Action) actionInvocation.getAction();
		if(action instanceof UserAware){
			((UserAware) action).setUser(user);
		}
		return actionInvocation.invoke();
	}
}
 
Example #5
Source File: AdminAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String executeJob() {
	try {
		ContentJobs contentJobs = new ContentJobs();
		// this._contentJobs.setApplicationContext(apx);
		ICategoryManager categoryManager = (ICategoryManager) ApsWebApplicationUtils.getBean(SystemConstants.CATEGORY_MANAGER,
				this.getRequest());
		IContentSchedulerManager contentSchedulerManager = (IContentSchedulerManager) ApsWebApplicationUtils
				.getBean("jpcontentschedulerContentSchedulerManager", this.getRequest());
		IContentManager contentManager = (IContentManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_MANAGER,
				this.getRequest());
		IPageManager pageManager = (IPageManager) ApsWebApplicationUtils.getBean(SystemConstants.PAGE_MANAGER, this.getRequest());
		IContentModelManager contentModelManager = (IContentModelManager) ApsWebApplicationUtils
				.getBean(JacmsSystemConstants.CONTENT_MODEL_MANAGER, this.getRequest());
		contentJobs.setCategoryManager(categoryManager);
		contentJobs.setContentManager(contentManager);
		contentJobs.setContentModelManager(contentModelManager);
		contentJobs.setContentSchedulerManager(contentSchedulerManager);
		contentJobs.setPageManager(pageManager);
		ApplicationContext ap = ApsWebApplicationUtils.getWebApplicationContext(this.getRequest());
		contentJobs.executeJob(ap);
	} catch (Throwable t) {
		_logger.error("Error executing job", t);
		return FAILURE;
	}
	return Action.SUCCESS;
}
 
Example #6
Source File: TestPageAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testDetailPageForAdmin() throws Throwable {
    String selectedPageCode = "contentview"; // PAGINA PREDISPOSTA PER LA
    // PUBBLICAZIONE VOLANTE
    String result = this.executeActionOnPage(selectedPageCode, "admin", "detail");
    assertEquals(Action.SUCCESS, result);

    IPage page = this._pageManager.getDraftPage(selectedPageCode);
    PageAction action = (PageAction) this.getAction();
    IPage pageToShow = action.getPageToShow();

    assertEquals(page.getCode(), pageToShow.getCode());
    assertEquals(page.getParentCode(), pageToShow.getParentCode());
    assertEquals(page.getModel().getCode(), pageToShow.getModel().getCode());
    assertEquals(page.getGroup(), pageToShow.getGroup());
    assertEquals(page.isShowable(), pageToShow.isShowable());
    assertEquals("Publicazione Contenuto", pageToShow.getTitles().getProperty("it"));
    assertEquals("Content Publishing", pageToShow.getTitles().getProperty("en"));
    Widget widget = page.getWidgets()[page.getModel().getMainFrame()];
    if (null != widget) {
        assertEquals("formAction", widget.getType().getCode());
        assertTrue(null != widget.getConfig() && !widget.getConfig().isEmpty());
    }
}
 
Example #7
Source File: TestUserSuspensionAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSuspend() throws Throwable {
	String username = "username_test";
	try {
		this.setUserOnSession("editorCoach");
		User user = new User();
		user.setDisabled(false);
		user.setUsername(username);
		user.setPassword(username);
		_userManager.addUser(user);
		this.setUserOnSession(username);
		this.initAction("/do/jpuserreg/UserReg", "suspend");
		this.addParameter("password", username);
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		user = (User) _userManager.getUser(username);
		assertNotNull(user);
		assertTrue(user.isDisabled());
	} finally {
		//		clean
		_userManager.removeUser(username);
	}
}
 
Example #8
Source File: TestFileBrowserAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testBrowseFileSystem_1() throws Throwable {
    String result = this.executeList("admin", null, null);
    assertEquals(Action.SUCCESS, result);
    FileBrowserAction action = (FileBrowserAction) super.getAction();
    BasicFileAttributeView[] fileAttributes = action.getFilesAttributes();
    assertNotNull(fileAttributes);
    assertEquals(2, fileAttributes.length);
    for (int i = 0; i < fileAttributes.length; i++) {
        BasicFileAttributeView bfav = fileAttributes[i];
        assertTrue(bfav instanceof RootFolderAttributeView);
        assertTrue(bfav.isDirectory());
        if (i == 0) {
            assertEquals("public", bfav.getName());
        } else {
            assertEquals("protected", bfav.getName());
        }
    }
}
 
Example #9
Source File: TestPageModelAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSave() throws Throwable {
    String testPageModelCode = "test_pagemodel";
    assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    try {
        PageModel mockModel = this.createMockPageModel(testPageModelCode);
        this.setUserOnSession("admin");
        this.initAction("/do/PageModel", "save");
        super.addParameter("code", mockModel.getCode());
        super.addParameter("description", mockModel.getDescription());
        super.addParameter("template", mockModel.getTemplate());
        PageModelDOM dom = new PageModelDOM(mockModel);
        super.addParameter("xmlConfiguration", dom.getXMLDocument());
        super.addParameter("strutsAction", ApsAdminSystemConstants.ADD);
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        assertNotNull(this._pageModelManager.getPageModel(testPageModelCode));
    } catch (Exception e) {
        throw e;
    } finally {
        this._pageModelManager.deletePageModel(testPageModelCode);
        assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    }
}
 
Example #10
Source File: TestFileBrowserAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testValidateAddTextFile() throws Throwable {
    String path = "conf/";
    try {
        String result = this.executeAddTextFile("developersConf", path, "filename", "css", "content", false);
        assertEquals("apslogin", result);

        result = this.executeAddTextFile("admin", path, "", "", "content", false);
        assertEquals(Action.INPUT, result);
        assertEquals(2, this.getAction().getFieldErrors().size());

        result = this.executeAddTextFile("admin", path, "filename", "", "", false);
        assertEquals(Action.INPUT, result);
        assertEquals(1, this.getAction().getFieldErrors().size());

        result = this.executeAddTextFile("admin", path, "filename", "exe", "content", false);
        assertEquals(Action.INPUT, result);
        assertEquals(1, this.getAction().getFieldErrors().size());

    } catch (Throwable t) {
        throw t;
    }
}
 
Example #11
Source File: ContentThreadConfigUsersAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String removeUser() {
	try {
		Map<String, List<String>> config = this.getUsersContentType();
		boolean isValidInput = this.validateRemoveUser();
		if (this.hasErrors()) {
			return INPUT;
		}
		if (isValidInput) {

			if (!config.containsKey(this.getUsername())) {
				return Action.SUCCESS;
			}
			config.remove(this.getUsername());
			this.setConfigItemOnSession(config);

			this.addActionMessage(this.getText("jpcontentscheduler.removeContentType.success"));
		}

	} catch (Throwable t) {
		_logger.error("Error in removeContentType", t);
		return FAILURE;
	}
	return Action.SUCCESS;
}
 
Example #12
Source File: TestBaseCommonAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSuccessfulUpdate() throws Throwable {
    String username = "editorCoach";
    String rightOldPassword = "editorCoach";
    String newPassword = "newPassword";
    this.setUserOnSession(username);
    UserDetails oldUser = this._userManager.getUser(username);
    try {
        String result = this.executeUpdate(rightOldPassword, newPassword, newPassword);
        assertEquals(Action.SUCCESS, result);

        UserDetails updatedUser = this._userManager.getUser(username, newPassword);
        assertNotNull(updatedUser);
    } catch (RuntimeException e) {
        throw e;
    } finally {
        this._userManager.changePassword(oldUser.getUsername(), oldUser.getUsername());
    }
}
 
Example #13
Source File: TestPageModelAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testTrashPageModels_2() throws Throwable {
    String testPageModelCode = "test_pagemodel";
    assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    try {
        PageModel mockModel = this.createMockPageModel(testPageModelCode);
        this._pageModelManager.addPageModel(mockModel);
        String result = this.executeAction("admin", "trash", testPageModelCode);
        assertEquals(Action.SUCCESS, result);
        PageModelAction pageModelAction = (PageModelAction) this.getAction();
        Map<String, List<Object>> references = pageModelAction.getReferences();
        assertTrue(null == references || references.isEmpty());
    } catch (Exception e) {
        throw e;
    } finally {
        this._pageModelManager.deletePageModel(testPageModelCode);
        assertNull(this._pageModelManager.getPageModel(testPageModelCode));
    }
}
 
Example #14
Source File: ContentActionIntegrationTest.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSaveNewContent() throws Throwable {
	String contentId = "ART1";
	Content master = this.getContentManager().loadContent(contentId, false);
	String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.ADD);
	master.setId(null);
	String descr = "Contenuto di prova per testSave";
	try {
		this.getRequest().getSession().setAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker, master);
		this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
		this.setUserOnSession("admin");
		this.addParameter("descr", "");
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
	} catch (Throwable t) {
		throw t;
	} finally {
		this.removeTestContent(descr);
	}
}
 
Example #15
Source File: TestResourceFinderAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSearchResources_3() throws Throwable {
    String result = this.executeSearchResource("admin", "Image", null, null, "jpg", null);
    assertEquals(Action.SUCCESS, result);
    ResourceFinderAction action = (ResourceFinderAction) this.getAction();
    assertEquals(3, action.getResources().size());
    assertEquals("jpg", action.getFileName());

    result = this.executeSearchResource("admin", "Image", null, null, "and", null);
    assertEquals(Action.SUCCESS, result);
    action = (ResourceFinderAction) this.getAction();
    assertEquals(2, action.getResources().size());
    assertEquals("and", action.getFileName());

    result = this.executeSearchResource("admin", "Image", null, null, "ando.JPG", null);
    assertEquals(Action.SUCCESS, result);
    action = (ResourceFinderAction) this.getAction();
    assertEquals(1, action.getResources().size());
    assertEquals("ando.JPG", action.getFileName());
}
 
Example #16
Source File: TestSubscribersAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testDeleteSubscriber() throws Throwable{
	String mail = "[email protected]";
	try {
		this.initAction("/do/jpnewsletter/Front/RegSubscriber", "addSubscription");
		this.addParameter("mailAddress", mail);
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		assertNotNull(this._newsletterManager.loadSubscriber(mail));
		this.setUserOnSession("admin");
		
		this.initAction("/do/jpnewsletter/Subscriber", "delete");
		this.addParameter("mailAddress", mail);
		result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		assertNull(this._newsletterManager.loadSubscriber(mail));
	} catch (Throwable t) {
		this._newsletterManager.deleteSubscriber(mail);
		throw t;
	}
}
 
Example #17
Source File: TestPageConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testConfigEditFrame() throws Throwable {
    String result = this.executeEditFrame("coach_page", -1, "pageManagerCoach");//invalid frame
    assertEquals("pageTree", result);
    assertEquals(1, this.getAction().getActionErrors().size());

    result = this.executeEditFrame("coach_page", 10, "pageManagerCoach");//frame out of range
    assertEquals("pageTree", result);
    assertEquals(1, this.getAction().getActionErrors().size());

    result = this.executeEditFrame("coach_page", 2, "pageManagerCoach");
    assertEquals("configureSpecialWidget", result);
    assertEquals(0, this.getAction().getActionErrors().size());

    result = this.executeEditFrame("contentview", 2, "pageManagerCoach");//user not allowed
    assertEquals("pageTree", result);
    assertEquals(1, this.getAction().getActionErrors().size());

    result = this.executeEditFrame("contentview", 2, "admin");
    assertEquals("configureSpecialWidget", result);
    assertEquals(0, this.getAction().getActionErrors().size());

    result = this.executeEditFrame("contentview", 1, "admin");
    assertEquals(Action.SUCCESS, result);
    assertEquals(0, this.getAction().getActionErrors().size());
}
 
Example #18
Source File: TestWidgetTypeAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testAddNewUserWidgetType() throws Throwable {
    String widgetTypeCode = "randomWidgetCode_3";
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/Portal/WidgetType", "save");
        this.addParameter("widgetTypeCode", widgetTypeCode);
        this.addParameter("englishTitle", "en");
        this.addParameter("italianTitle", "it");
        this.addParameter("parentWidgetTypeCode", "formAction");
        this.addParameter("strutsAction", WidgetTypeAction.NEW_USER_WIDGET);
        this.addParameter("actionPath", "/myjsp.jsp");
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);

        WidgetType addedType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
        assertNotNull(addedType);
        ApsProperties config = addedType.getConfig();
        assertEquals(1, config.size());
        assertEquals("/myjsp.jsp", config.getProperty("actionPath"));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
    }
}
 
Example #19
Source File: TestContentGroupAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testInsertOnLineContents_3() throws Throwable {
	this.setUserOnSession("admin");
	String[] masterContentIds = {"ART179"};//CONTENUTO FREE con errori di validazione
	String[] newContentIds = null;
	try {
		newContentIds = this.addDraftContentsForTest(masterContentIds, false);
		for (int i=0; i<newContentIds.length; i++) {
			Content content = this.getContentManager().loadContent(newContentIds[i], false);
			assertFalse(content.isOnLine());
		}
		this.initAction("/do/jacms/Content", "approveContentGroup");
		this.addParameter("contentIds", newContentIds);
		String result = this.executeAction();
		assertEquals(Action.SUCCESS, result);
		ActionSupport action = this.getAction();
		Collection<String> messages = action.getActionMessages();
		assertEquals(0, messages.size());
		Collection<String> errors = action.getActionErrors();
		assertEquals(1, errors.size());
	} catch (Throwable t) {
		throw t;
	} finally {
		this.deleteContents(newContentIds);
	}
}
 
Example #20
Source File: TestRssAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testDelete() throws Throwable {
	Channel channel1 = this.createTestChannel("t1", "d1", true);
	this.getRssManager().addChannel(channel1);
	
	this.setUserOnSession("admin");
	this.initAction(NAMESPACE, "delete");
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	assertTrue(this.getAction().getActionErrors().size() == 1);
	
	this.initAction(NAMESPACE, "delete");
	String id = new Integer(channel1.getId()).toString();
	this.addParameter("id", id);
	result = this.executeAction();
	assertEquals(Action.SUCCESS, result);
	List<Channel> channels = this.getRssManager().getChannels(Channel.STATUS_ALL);
	assertTrue(channels.isEmpty());
}
 
Example #21
Source File: TestWidgetTypeAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureUpdateTitles() throws Throwable {
    String result = this.executeUpdate("content_viewer", "italian title", "english title", "editorCustomers", "*GUI*");
    assertEquals("userNotAllowed", result);

    result = this.executeUpdate("content_viewer", "italian title", "", "admin", null);
    assertEquals(Action.INPUT, result);
    assertEquals(2, this.getAction().getFieldErrors().size());

    result = this.executeUpdate("leftmenu", "italian title", "", "admin", null);
    assertEquals(Action.INPUT, result);
    assertEquals(2, this.getAction().getFieldErrors().size());

    result = this.executeUpdate("leftmenu", "italian title", "", "admin", "*GUI*");
    assertEquals(Action.INPUT, result);
    assertEquals(1, this.getAction().getFieldErrors().size());

    result = this.executeUpdate("invalidWidgetTitles", "italian title", "english title", "admin", "*GUI*");
    assertEquals(Action.INPUT, result);
    assertEquals(1, this.getAction().getFieldErrors().size());
}
 
Example #22
Source File: TestPageTreeAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testCopyForAdminUser() throws Throwable {
    String pageToCopy = this._pageManager.getDraftRoot().getCode();
    this.executeCopyPage(pageToCopy, "admin");

    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    PageAction action = (PageAction) this.getAction();
    String copyingPageCode = action.getSelectedNode();
    assertEquals(pageToCopy, copyingPageCode);
    assertEquals(pageToCopy, action.getParentPageCode());

    this.executeCopyPage("wrongPageCode", "admin");
    result = this.executeAction();
    assertEquals("pageTree", result);
    action = (PageAction) this.getAction();
    copyingPageCode = action.getSelectedNode();
    assertNotNull(copyingPageCode);
    assertNull(action.getParentPageCode());
    assertEquals(1, action.getActionErrors().size());
}
 
Example #23
Source File: TestWidgetsViewerAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testGetWidgetUtilizers_1() throws Throwable {
    String result = this.executeViewWidgetUtilizers("admin", null);
    assertEquals(Action.INPUT, result);
    Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
    assertEquals(1, fieldErrors.size());
    assertEquals(1, fieldErrors.get("showletTypeCode").size());

    result = this.executeViewWidgetUtilizers("admin", "");
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors();
    assertEquals(1, fieldErrors.size());
    assertEquals(1, fieldErrors.get("showletTypeCode").size());

    result = this.executeViewWidgetUtilizers("admin", "invalidShowletCode");
    assertEquals(Action.INPUT, result);
    fieldErrors = this.getAction().getFieldErrors();
    assertEquals(1, fieldErrors.size());
    assertEquals(1, fieldErrors.get("showletTypeCode").size());
}
 
Example #24
Source File: TestVersionFinderAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testList() throws Throwable{
	String result = this.executeList("admin");
	assertEquals(Action.SUCCESS, result);
	
	VersionFinderAction action = (VersionFinderAction) this.getAction();
	List<Long> lastVersionsId = action.getLatestVersions();
	assertEquals(1, lastVersionsId.size());
	assertEquals(3, lastVersionsId.get(0).longValue());
	
	ContentVersion contentVersion = action.getContentVersion(3);
	assertEquals(3, contentVersion.getId());
	assertEquals("1.0", contentVersion.getVersion());
	assertEquals(1, contentVersion.getOnlineVersion());
	assertEquals("ART1", contentVersion.getContentId());
	assertEquals("ART", contentVersion.getContentType());
	assertEquals("Articolo 3", contentVersion.getDescr());
	assertNotNull(contentVersion.getVersionDate());
	assertNotNull(contentVersion.getXml());
}
 
Example #25
Source File: TestCategoryAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testEditCategory() throws Throwable {
    this.setUserOnSession("admin");
    this.initAction("/do/Category", "edit");
    String result = this.executeAction();
    assertEquals("categoryTree", result);
    CategoryAction action = (CategoryAction) this.getAction();
    assertEquals(1, action.getActionErrors().size());

    this.setUserOnSession("admin");
    this.initAction("/do/Category", "edit");
    this.addParameter("selectedNode", "evento");
    result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    action = (CategoryAction) this.getAction();
    assertEquals(this._categoryManager.getRoot().getCode(), action.getParentCategoryCode());
    assertEquals(2, action.getTitles().size());
    assertEquals(ApsAdminSystemConstants.EDIT, action.getStrutsAction());
}
 
Example #26
Source File: ContentThreadConfigContentTypesAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String addContentType() {
    try {
        boolean alreadyExist = false;
        List<ContentTypeElem> config = this.getTypes();
        ContentTypeElem elem = this.getContentTypeElem();
        elem.setIdsCategories(this.getCategoryCodes());
        ContentTypeElem existingElem = null;
        for (int i = 0; i < config.size(); i++) {
            if (config.get(i).getContentType().equalsIgnoreCase(elem.getContentType())) {
                alreadyExist = true;
                config.set(i, elem);
                break;
            }
        }
        if (!alreadyExist) {
            config.add(elem);
        }

        this.setConfigItemOnSession(config);

    } catch (Throwable t) {
        _logger.error("Error in addContentType", t);
        return FAILURE;
    }
    return Action.SUCCESS;
}
 
Example #27
Source File: TestTrashedResourceAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testRemoveFromTrash() throws Throwable{
	String resourceId = "22";
	try {
		ResourceInterface resource = this._resourceManager.loadResource(resourceId);
		this._trashedResourceDAO.addTrashedResource(resource);
		
		String result = this.executeList("admin", "Image");
		assertEquals(Action.SUCCESS, result);
		List<String> trashedResources = ((TrashedResourceAction) this.getAction()).getTrashedResources();
		assertTrue(trashedResources.contains(resourceId));
		
		result = this.executeRemove("admin", "Image", resourceId);
		assertEquals(Action.SUCCESS, result);
		assertNull(this._trashedResourceDAO.getTrashedResource(resourceId));
	} catch (Throwable t) {
		this._trashedResourceDAO.delTrashedResource(resourceId);
		throw t;
	}
}
 
Example #28
Source File: TestShortcutConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testJoinMyShortcut_2() throws Throwable {
	UserDetails user = this.getUser("admin");
	try {
		String result = this.executeJoinMyShortcut("core.tools.setting", 9, "admin", ApsAdminSystemConstants.ADD);
		assertEquals(Action.SUCCESS, result);
		String[] newConfig = this._shortcutManager.getUserConfig(user);
		for (int i = 0; i < newConfig.length; i++) {
			if (i==9) {
				assertEquals("core.tools.setting", newConfig[i]);
			} else {
				assertEquals(ADMIN_CONFIG[i], newConfig[i]);
			}
		}
	} catch (Exception e) {
		throw e;
	} finally {
		this._shortcutManager.saveUserConfig(user, ADMIN_CONFIG);
	}
}
 
Example #29
Source File: TestExtendedResourceFinderAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSearchImageResource_1() throws Throwable {
    this.executeEdit("ART1", "admin");//Contenuto FREE
    String contentOnSessionMarker = super.extractSessionMarker("ART1", ApsAdminSystemConstants.EDIT);

    //iniziazione parametri sessione
    HttpSession session = this.getRequest().getSession();
    session.setAttribute(ResourceAttributeActionHelper.ATTRIBUTE_NAME_SESSION_PARAM, "Foto");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_TYPE_CODE_SESSION_PARAM, "Image");
    session.setAttribute(ResourceAttributeActionHelper.RESOURCE_LANG_CODE_SESSION_PARAM, "it");

    this.initContentAction("/do/jacms/Content/Resource", "search", contentOnSessionMarker);
    this.addParameter("resourceTypeCode", "Image");//per replicare il chain in occasione dei chooseResource da edit Contenuto.
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);

    ResourceFinderAction action = (ResourceFinderAction) this.getAction();
    assertEquals(2, action.getResources().size());
    assertEquals("22", action.getResources().get(0));
    assertEquals("44", action.getResources().get(1));
}
 
Example #30
Source File: TestPageAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSavePage_Draft_1() throws Throwable {
    String pageCode = "pagina_test_1";
    assertNull(this._pageManager.getDraftPage(pageCode));
    try {
        IPage root = this._pageManager.getDraftRoot();
        Map<String, String> params = new HashMap<String, String>();
        params.put("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
        params.put("parentPageCode", root.getCode());
        params.put("langit", "Pagina Test 1");
        params.put("langen", "Test Page 1");
        params.put("model", "home");
        params.put("group", Group.FREE_GROUP_NAME);
        params.put("pageCode", pageCode);
        String result = this.executeSave(params, "admin");
        assertEquals(Action.SUCCESS, result);
        IPage addedPage = this._pageManager.getDraftPage(pageCode);
        assertNotNull(addedPage);
        assertEquals("Pagina Test 1", addedPage.getMetadata().getTitles().getProperty("it"));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._pageManager.deletePage(pageCode);
    }
}