Search in sources :

Example 16 with Action

use of com.opensymphony.xwork2.Action in project entando-core by entando.

the class TestContentGroupAction method testInsertOnLineContents_1.

public void testInsertOnLineContents_1() throws Throwable {
    this.setUserOnSession("admin");
    // CONTENUTI FREE
    String[] masterContentIds = { "ART111", "EVN20" };
    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);
        for (int i = 0; i < newContentIds.length; i++) {
            Content content = this.getContentManager().loadContent(newContentIds[i], false);
            assertTrue(content.isOnLine());
        }
        ActionSupport action = this.getAction();
        Collection<String> messages = action.getActionMessages();
        assertEquals(1, messages.size());
    } catch (Throwable t) {
        throw t;
    } finally {
        this.deleteContents(newContentIds);
    }
}
Also used : Content(com.agiletec.plugins.jacms.aps.system.services.content.model.Content) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Example 17 with Action

use of com.opensymphony.xwork2.Action in project entando-core by entando.

the class TestIntroNewContentAction method testCreateNewVoid_2.

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());
}
Also used : ActionSupport(com.opensymphony.xwork2.ActionSupport) List(java.util.List)

Example 18 with Action

use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionService method internalProcessActions.

protected Field internalProcessActions(Actions actions, Object sourceObject, FieldType targetType) throws AtlasException {
    Field processedField = new SimpleField();
    processedField.setValue(sourceObject);
    processedField.setFieldType(targetType);
    if (FieldType.COMPLEX.equals(targetType)) {
        return processedField;
    }
    Object tmpSourceObject = sourceObject;
    FieldType sourceType = (sourceObject != null ? getConversionService().fieldTypeFromClass(sourceObject.getClass()) : FieldType.NONE);
    if (actions == null || actions.getActions() == null || actions.getActions().isEmpty()) {
        if (sourceObject == null) {
            return processedField;
        }
        processedField.setValue(getConversionService().convertType(sourceObject, sourceType, targetType));
        processedField.setFieldType(targetType);
        return processedField;
    }
    FieldType currentType = sourceType;
    for (Action action : actions.getActions()) {
        ActionDetail detail = findActionDetail(action.getDisplayName(), currentType);
        if (!detail.getSourceType().equals(currentType) && !FieldType.ANY.equals(detail.getSourceType())) {
            tmpSourceObject = getConversionService().convertType(sourceObject, currentType, detail.getSourceType());
        }
        processedField.setValue(processAction(action, detail, tmpSourceObject));
        processedField.setFieldType(detail.getTargetType());
        currentType = detail.getTargetType();
    }
    return processedField;
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) AtlasFieldAction(io.atlasmap.api.AtlasFieldAction) Action(io.atlasmap.v2.Action) ActionDetail(io.atlasmap.v2.ActionDetail) SimpleField(io.atlasmap.v2.SimpleField) FieldType(io.atlasmap.v2.FieldType)

Example 19 with Action

use of com.opensymphony.xwork2.Action in project weicoder by wdcode.

the class StrutsAction method getAction.

/**
 * 获得当前Action
 * @param <E> 泛型
 * @return Action
 */
@SuppressWarnings("unchecked")
public <E extends Action> E getAction() {
    // 获得值栈里的对象
    Object action = ActionContext.getContext().getValueStack().peek();
    // 判断对象是Action类型的
    if (action instanceof Action) {
        // 返回Action
        return (E) action;
    }
    // 获得Action拦截器
    ActionInvocation ai = ActionContext.getContext().getActionInvocation();
    // 如果拦截器不为空
    if (ai != null) {
        return (E) ai.getAction();
    }
    // 如果都不符合返回null
    return null;
}
Also used : Action(com.opensymphony.xwork2.Action) ActionInvocation(com.opensymphony.xwork2.ActionInvocation)

Example 20 with Action

use of com.opensymphony.xwork2.Action in project entando-core by entando.

the class TestCustomTokenInterceptor method testExecuteValidation_1.

public void testExecuteValidation_1() throws Exception {
    ActionInvocation invocation = this.prepareAction();
    CustomTokenInterceptor interceptor = new CustomTokenInterceptor();
    String result = interceptor.intercept(invocation);
    assertEquals(Action.SUCCESS, result);
    String newResult = interceptor.intercept(invocation);
    assertEquals(CustomTokenInterceptor.INVALID_TOKEN_CODE, newResult);
    ActionSupport action = super.getAction();
    assertEquals(0, action.getActionErrors().size());
    assertEquals(0, action.getActionMessages().size());
}
Also used : ActionInvocation(com.opensymphony.xwork2.ActionInvocation) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Aggregations

ActionSupport (com.opensymphony.xwork2.ActionSupport)61 List (java.util.List)40 Action (io.atlasmap.v2.Action)35 ArrayList (java.util.ArrayList)23 Test (org.junit.jupiter.api.Test)16 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)14 SimpleField (io.atlasmap.v2.SimpleField)13 Field (io.atlasmap.v2.Field)12 Mapping (io.atlasmap.v2.Mapping)11 ActionContext (com.opensymphony.xwork2.ActionContext)9 AtlasMapping (io.atlasmap.v2.AtlasMapping)9 Collections (java.util.Collections)9 HashMap (java.util.HashMap)9 SettableApiFuture (com.google.api.core.SettableApiFuture)8 ServiceOptions (com.google.cloud.ServiceOptions)8 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)8 Subscriber (com.google.cloud.pubsub.v1.Subscriber)8 Action (com.google.privacy.dlp.v2.Action)8 BigQueryTable (com.google.privacy.dlp.v2.BigQueryTable)8 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)8