Java Code Examples for com.opensymphony.xwork2.ActionSupport#getFieldErrors()

The following examples show how to use com.opensymphony.xwork2.ActionSupport#getFieldErrors() . 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: TestMultipleResourceAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testSaveNewResource_2() throws Throwable {
    String insertedDescr = "Description ";
    while (insertedDescr.length() < 300) {
        insertedDescr += insertedDescr;
    }
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/Resource", "save");
    this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
    this.addParameter("descr_0", insertedDescr);
    this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
    String result = this.executeAction();
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    Map<String, List<String>> actionFieldErrors = action.getFieldErrors();
    assertEquals(5, actionFieldErrors.size());
    assertEquals(1, actionFieldErrors.get("resourceTypeCode").size());

}
 
Example 2
Source File: TestTextAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddTextFilter() throws Throwable {
	Map<String, String> params = this.getBaseParams("NEW");
	params.put("filterKey", "Title");
	params.put("attributeFilter", "true");
	params.put("filterTypeId", String.valueOf(IContentListFilterAction.TEXT_ATTRIBUTE_FILTER_TYPE));//Tipo Stringa
	params.put("filterOptionId", String.valueOf(IContentListFilterAction.VALUE_FILTER_OPTION));//Opzione "Value"
	params.put("stringValue", "");
	String result = this.executeAddFilter("admin", params, "saveTextFilter");
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> stringValueErrors = fieldsErrors.get("stringValue");
	assertEquals(1, stringValueErrors.size());
}
 
Example 3
Source File: TestIntroNewContentAction.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testCreateNewVoid_5() throws Throwable {
	this.setUserOnSession("editorCustomers");
	this.initAction("/do/jacms/Content", "createNewVoid");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "Description");
	this.addParameter("contentMainGroup", Group.FREE_GROUP_NAME);
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErros = action.getFieldErrors();
	assertEquals(1, fieldErros.size());
	assertEquals(1, fieldErros.get("contentMainGroup").size());

	this.initAction("/do/jacms/Content", "createNewVoid");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "Description");
	this.addParameter("contentMainGroup", "customers");
	result = this.executeAction();
	assertEquals(Action.SUCCESS, result);
}
 
Example 4
Source File: TestNavigatorWidgetConfigAction.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void testFailureAddExpression_1() throws Throwable {
	Map<String, String> params = new HashMap<String, String>();
	params.put("pageCode", "pagina_2");
	params.put("frame", "3");
	params.put("widgetTypeCode", "leftmenu");
	params.put("navSpec", "parent.subtree(2)+abs(1).subtree(2)+current");
	String result = this.executeAddExpression("admin", params);
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	assertEquals(1, fieldErrors.get("specId").size());

	NavigatorWidgetConfigAction navAction = (NavigatorWidgetConfigAction) action;
	Widget widget = navAction.getWidget();
	assertNotNull(widget);
	ApsProperties props = widget.getConfig();
	assertEquals(0, props.size());
	assertEquals("parent.subtree(2)+abs(1).subtree(2)+current", navAction.getNavSpec());
	assertEquals(3, navAction.getExpressions().size());
}
 
Example 5
Source File: TestIntroNewContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testCreateNewVoid_4() throws Throwable {
	this.initAction("/do/jacms/Content", "createNewVoid");
	this.setUserOnSession("admin");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "Description");
	this.addParameter("contentMainGroup", "invalidGroupCode");
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErros = action.getFieldErrors();
	assertEquals(1, fieldErros.size());
	assertEquals(1, fieldErros.get("contentMainGroup").size());
}
 
Example 6
Source File: TestIntroNewContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testCreateNewVoid_2() throws Throwable {
	this.initAction("/do/jacms/Content", "createNewVoid");
	this.setUserOnSession("admin");
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErros = action.getFieldErrors();
	assertEquals(3, fieldErros.size());
}
 
Example 7
Source File: TestContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testValidate_3() throws Throwable { // Description maxlength
    String contentTypeCode = "ART";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String marker = "__DESCR_TEST__";
    String insertedDescr = marker;
    while (insertedDescr.length() < 300) {
        insertedDescr += marker;
    }
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr",
                Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);

        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        result = this.executeAction();
        assertEquals(Action.INPUT, result);

        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(2, fieldErros.size());

        List<String> descrFieldsErrors = fieldErros.get("descr");
        assertEquals(1, descrFieldsErrors.size());
        List<String> titleFieldsErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleFieldsErrors.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
 
Example 8
Source File: TestContentFinderViewerAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureJoinContent_1() throws Throwable {
	String result = this.executeJoinContent("admin", "pagina_11", "1", null);//ID Nullo
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	List<String> contentIdFieldErrors = fieldErrors.get("contentId");
	assertEquals(1, contentIdFieldErrors.size());
}
 
Example 9
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeDateFilter_3() throws Throwable {
	String result = this.executeSaveRangeDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "25/09/1972", //Data Start inserita
			IContentListFilterAction.INSERTED_DATE_FILTER, "wrongFormat");// Data End Inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateEnd");
	assertEquals(2, dateValueErrors.size());//dateEnd Wrong Format and dateEnd required
}
 
Example 10
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeDateFilter_2() throws Throwable {
	String result = this.executeSaveRangeDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "25/09/1972", //Data Start inserita
			IContentListFilterAction.INSERTED_DATE_FILTER, "21/04/1972");// Data End Inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateEnd");
	assertEquals(1, dateValueErrors.size());//dateStart.after(dateEnd)
}
 
Example 11
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeDateFilter_1() throws Throwable {
	String result = this.executeSaveRangeDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "", //Data Start inserita
			IContentListFilterAction.INSERTED_DATE_FILTER, "25/09/1972");// Data End Inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateStart");
	assertEquals(1, dateValueErrors.size());//required dateStart
}
 
Example 12
Source File: TestContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testValidate_6() throws Throwable {
    String contentTypeCode = "RAH";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String longDescr = IntStream.range(0, 25).mapToObj(i -> "1234567890 ").collect(Collectors.joining());
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr",
                Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);

        this.initContentAction("/do/jacms/Content", "saveAndContinue", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", longDescr);

        result = this.executeAction();
        assertEquals(Action.SUCCESS, result);

        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        List<String> descrFieldErrors = fieldErros.get("descr");
        assertEquals(1, descrFieldErrors.size());

        EntitySearchFilter filter1 = new EntitySearchFilter(IContentManager.CONTENT_MODIFY_DATE_FILTER_KEY, false);
        filter1.setOrder(EntitySearchFilter.DESC_ORDER);
        EntitySearchFilter filter2 = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false, longDescr, false);
        EntitySearchFilter[] filters = {filter1, filter2};
        List<String> contentsId = this.getContentManager().searchId(filters);
        assertEquals(0, contentsId.size());
    } catch (Throwable t) {
        this.removeTestContent(longDescr);
        throw t;
    }
}
 
Example 13
Source File: TestDateAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddDateValueFilter_2() throws Throwable {
	String result = this.executeSaveValueDateFilter(IContentListFilterAction.INSERTED_DATE_FILTER, "");//Opzione Data inserita
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> dateValueErrors = fieldsErrors.get("dateValue");
	assertEquals(1, dateValueErrors.size());
}
 
Example 14
Source File: TestNumberAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddRangeNumberFilter_1() throws Throwable {
	String result = this.executeSaveRangeNumberFilter("", "");
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> numberValueErrors = fieldsErrors.get("numberEnd");
	assertEquals(1, numberValueErrors.size());//richiesto uno dei campi
}
 
Example 15
Source File: TestNumberAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddNumberValueFilter_2() throws Throwable {
	String result = this.executeSaveNumberValueFilter("wrongFormat");
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> numberValueErrors = fieldsErrors.get("numberValue");
	assertEquals(2, numberValueErrors.size());//Errore in conversione e messaggio campo obbligatorio
}
 
Example 16
Source File: TestNumberAttributeFilterAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testFailureAddNumberValueFilter_1() throws Throwable {
	String result = this.executeSaveNumberValueFilter("");
	assertEquals(Action.INPUT, result);
	
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldsErrors = action.getFieldErrors();
	assertEquals(1, fieldsErrors.size());
	List<String> numberValueErrors = fieldsErrors.get("numberValue");
	assertEquals(1, numberValueErrors.size());
}
 
Example 17
Source File: TestIntroNewContentAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testCreateNewVoid_3() throws Throwable {
	this.initAction("/do/jacms/Content", "createNewVoid");
	this.setUserOnSession("admin");
	this.addParameter("contentTypeCode", "ART");
	this.addParameter("contentDescription", "");
	String result = this.executeAction();
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErros = action.getFieldErrors();
	assertEquals(2, fieldErros.size());
	assertEquals(1, fieldErros.get("contentDescription").size());
	assertEquals(1, fieldErros.get("contentMainGroup").size());
}
 
Example 18
Source File: TestMultipleResourceAction.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testSaveNewResourceStrutsValidation() throws Throwable {
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/Resource", "save");
    this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.ADD));
    String result = this.executeAction();
    assertEquals(Action.INPUT, result);
    ActionSupport action = this.getAction();
    Map<String, List<String>> actionFieldErrors = action.getFieldErrors();
    assertEquals(6, actionFieldErrors.size());
    assertEquals(1, actionFieldErrors.get("resourceTypeCode").size());
    assertEquals(1, actionFieldErrors.get("mainGroup").size());
}
 
Example 19
Source File: TestContentAction.java    From entando-components with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void testValidate_5() throws Throwable {
    String contentTypeCode = "RAH";
    String contentOnSessionMarker = this.extractSessionMarker(contentTypeCode, ApsAdminSystemConstants.ADD);
    String insertedDescr = "XXX Prova Validazione XXX";
    String shortTitle = "short";
    String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; "
            + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
    try {
        String result = this.executeCreateNewVoid(contentTypeCode, "descr",
                Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
        assertEquals(Action.SUCCESS, result);
        Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
        assertNotNull(contentOnSession);

        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", shortTitle);

        result = this.executeAction();
        assertEquals(Action.INPUT, result);

        ActionSupport action = this.getAction();
        Map<String, List<String>> fieldErros = action.getFieldErrors();

        assertEquals(1, fieldErros.size());

        List<String> titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());

        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", longTitle);

        result = this.executeAction();
        assertEquals(Action.INPUT, result);

        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:it_Titolo");
        assertEquals(1, titleItFieldErrors.size());

        this.initContentAction("/do/jacms/Content", "save", contentOnSessionMarker);
        this.setUserOnSession("admin");
        this.addParameter("mainGroup", Group.FREE_GROUP_NAME);
        this.addParameter("descr", insertedDescr);
        this.addParameter("Text:it_Titolo", "Right Title length");
        this.addParameter("Text:en_Titolo", longTitle);

        result = this.executeAction();
        assertEquals(Action.INPUT, result);

        action = this.getAction();
        fieldErros = action.getFieldErrors();
        assertEquals(1, fieldErros.size());
        titleItFieldErrors = fieldErros.get("Text:en_Titolo");
        assertEquals(1, titleItFieldErrors.size());

    } catch (Throwable t) {
        throw t;
    } finally {
        this.removeTestContent(insertedDescr);
    }
}
 
Example 20
Source File: TestRoleAction.java    From entando-core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void testFailureSave() throws Throwable {
	this.executeNew("admin");
	String[] permissions = { "editContents" };
	
	// permessi non disponibili
	String result = this.executeSaveNew("developersConf", "roleName", "description", permissions);
	assertEquals("apslogin", result);
	
	// roleName giĆ  esistente
	result = this.executeSaveNew("admin", "editor", "description", permissions);
	assertEquals(Action.INPUT, result);
	ActionSupport action = this.getAction();
	Map<String, List<String>> fieldErrors = action.getFieldErrors();
	assertEquals(1, fieldErrors.size());
	List<String> errors = fieldErrors.get("name");
	assertEquals(1, errors.size());
	
	// description non valorizzato
	result = this.executeSaveNew("admin", "roleName", "", permissions);
	assertEquals(Action.INPUT, result);
	fieldErrors = this.getAction().getFieldErrors();
	assertEquals(1, fieldErrors.size());
	errors = fieldErrors.get("description");
	assertEquals(1, errors.size());
	
	// name e description non valorizzati
	result = this.executeSaveNew("admin", "", "", permissions);
	assertEquals(Action.INPUT, result);
	fieldErrors = this.getAction().getFieldErrors();
	assertEquals(2, fieldErrors.size());
	errors = fieldErrors.get("name");
	assertEquals(1, errors.size());
	errors = fieldErrors.get("description");
	assertEquals(1, errors.size());
	
	// name troppo lungo
	result = this.executeSaveNew("admin", "roleNameDecisamenteTroppoLungo", "description", permissions);
	assertEquals(Action.INPUT, result);
	fieldErrors = this.getAction().getFieldErrors();
	assertEquals(1, fieldErrors.size());
	errors = fieldErrors.get("name");
	assertEquals(1, errors.size());
}