Search in sources :

Example 6 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelAction method testEdit.

public void testEdit() throws Throwable {
    long modelId = 1;
    this.setUserOnSession("admin");
    this.initAction("/do/jacms/ContentModel", "edit");
    ContentModelAction action = (ContentModelAction) this.getAction();
    this.addParameter("modelId", Long.valueOf(modelId).toString());
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    assertEquals(ApsAdminSystemConstants.EDIT, action.getStrutsAction());
    ContentModel currentModel = _contentModelManager.getContentModel(modelId);
    assertEquals(currentModel.getId(), new Long(action.getModelId()).longValue());
    assertEquals(currentModel.getContentShape(), action.getContentShape());
    assertEquals(currentModel.getContentType(), action.getContentType());
    assertEquals(currentModel.getDescription(), action.getDescription());
    assertEquals(currentModel.getStylesheet(), action.getStylesheet());
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 7 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelAction method testUpdateModel.

public void testUpdateModel() throws Throwable {
    List<ContentModel> eventModels = this._contentModelManager.getModelsForContentType("EVN");
    assertEquals(0, eventModels.size());
    long modelId = 99;
    this.addModelForTest(modelId, "EVN");
    eventModels = this._contentModelManager.getModelsForContentType("EVN");
    assertEquals(1, eventModels.size());
    ContentModel model = (ContentModel) eventModels.get(0);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/jacms/ContentModel", "save");
        this.addParameter("strutsAction", new Integer(ApsAdminSystemConstants.EDIT).toString());
        this.addParameter("modelId", new Long(modelId).toString());
        this.addParameter("description", "updated description");
        this.addParameter("contentType", model.getContentType());
        this.addParameter("contentShape", model.getContentShape());
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        eventModels = this._contentModelManager.getModelsForContentType("EVN");
        assertEquals(1, eventModels.size());
        model = this._contentModelManager.getContentModel(modelId);
        assertEquals("updated description", model.getDescription());
    } catch (Throwable t) {
        throw t;
    } finally {
        model = this._contentModelManager.getContentModel(modelId);
        if (null != model) {
            this._contentModelManager.removeContentModel(model);
        }
        eventModels = this._contentModelManager.getModelsForContentType("EVN");
        assertEquals(0, eventModels.size());
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 8 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelAction method addModelForTest.

private void addModelForTest(long id, String contentType) throws Throwable {
    ContentModel model = new ContentModel();
    model.setId(id);
    model.setContentType(contentType);
    model.setDescription("contentModel description");
    model.setContentShape("contentShape field value");
    this._contentModelManager.addContentModel(model);
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Example 9 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelAction method testSaveWithErrors_3.

public void testSaveWithErrors_3() throws Throwable {
    String veryLongDescription = "Very but very very very long description (upper than 50 characters) for invoke description's length validation";
    int negativeModelId = 0;
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/jacms/ContentModel", "save");
        addParameter("contentType", "EVN");
        addParameter("strutsAction", new Integer(ApsAdminSystemConstants.ADD).toString());
        addParameter("description", veryLongDescription);
        addParameter("contentShape", "contentShape field value");
        addParameter("modelId", String.valueOf(negativeModelId));
        String result = this.executeAction();
        assertEquals(Action.INPUT, result);
        Map<String, List<String>> fieldErrors = this.getAction().getFieldErrors();
        assertEquals(2, fieldErrors.size());
        assertEquals(1, fieldErrors.get("modelId").size());
        assertEquals(1, fieldErrors.get("description").size());
    } catch (Throwable t) {
        throw t;
    } finally {
        ContentModel model = this._contentModelManager.getContentModel(negativeModelId);
        if (null != model) {
            this._contentModelManager.removeContentModel(model);
        }
    }
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel) List(java.util.List)

Example 10 with ContentModel

use of com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel in project entando-core by entando.

the class TestContentModelFinderAction method testSearch_2.

public void testSearch_2() throws Throwable {
    ContentModel contentModel = this.createContentModel(MODEL_ID, "EVN");
    this._contentModelManager.addContentModel(contentModel);
    String result = this.executeSearch("");
    assertEquals(Action.SUCCESS, result);
    IContentModelFinderAction contentModelFinderAction = (IContentModelFinderAction) this.getAction();
    List<ContentModel> contentModels = contentModelFinderAction.getContentModels();
    assertEquals(5, contentModels.size());
    result = this.executeSearch("EVN");
    assertEquals(Action.SUCCESS, result);
    contentModelFinderAction = (IContentModelFinderAction) this.getAction();
    contentModels = contentModelFinderAction.getContentModels();
    assertEquals(1, contentModels.size());
}
Also used : ContentModel(com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)

Aggregations

ContentModel (com.agiletec.plugins.jacms.aps.system.services.contentmodel.ContentModel)27 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)3 RequestContext (com.agiletec.aps.system.RequestContext)2 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 SmallContentType (com.agiletec.plugins.jacms.aps.system.services.content.model.SmallContentType)1 ContentRenderizationInfo (com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringListApiResponse (org.entando.entando.aps.system.services.api.model.StringListApiResponse)1 Cache (org.springframework.cache.Cache)1