Search in sources :

Example 6 with DataObjectModel

use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.

the class TestDataObjectModelAction method testUpdateModel.

public void testUpdateModel() throws Throwable {
    List<DataObjectModel> eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
    assertEquals(0, eventModels.size());
    long modelId = 99;
    this.addModelForTest(modelId, "EVN");
    eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
    assertEquals(1, eventModels.size());
    DataObjectModel model = (DataObjectModel) eventModels.get(0);
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/dataobject/model", "save");
        this.addParameter("strutsAction", new Integer(ApsAdminSystemConstants.EDIT).toString());
        this.addParameter("modelId", new Long(modelId).toString());
        this.addParameter("description", "updated description");
        this.addParameter("dataType", model.getDataType());
        this.addParameter("dataObjectShape", model.getShape());
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
        assertEquals(1, eventModels.size());
        model = this._dataObjectModelManager.getDataObjectModel(modelId);
        assertEquals("updated description", model.getDescription());
    } catch (Throwable t) {
        throw t;
    } finally {
        model = this._dataObjectModelManager.getDataObjectModel(modelId);
        if (null != model) {
            this._dataObjectModelManager.removeDataObjectModel(model);
        }
        eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
        assertEquals(0, eventModels.size());
    }
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 7 with DataObjectModel

use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.

the class TestDataObjectModelAction method addModelForTest.

private void addModelForTest(long id, String dataType) throws Throwable {
    DataObjectModel model = new DataObjectModel();
    model.setId(id);
    model.setDataType(dataType);
    model.setDescription("dataObjectModel description");
    model.setShape("dataObjectShape field value");
    this._dataObjectModelManager.addDataObjectModel(model);
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 8 with DataObjectModel

use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.

the class TestDataObjectModelAction 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/dataobject/model", "save");
        addParameter("dataType", "EVN");
        addParameter("strutsAction", new Integer(ApsAdminSystemConstants.ADD).toString());
        addParameter("description", veryLongDescription);
        addParameter("dataObjectShape", "dataObjectShape 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 {
        DataObjectModel model = this._dataObjectModelManager.getDataObjectModel(negativeModelId);
        if (null != model) {
            this._dataObjectModelManager.removeDataObjectModel(model);
        }
    }
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel) List(java.util.List)

Example 9 with DataObjectModel

use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.

the class TestDataObjectModelAction method testEdit.

public void testEdit() throws Throwable {
    long modelId = 1;
    this.setUserOnSession("admin");
    this.initAction("/do/dataobject/model", "edit");
    DataObjectModelAction action = (DataObjectModelAction) this.getAction();
    this.addParameter("modelId", Long.valueOf(modelId).toString());
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);
    assertEquals(ApsAdminSystemConstants.EDIT, action.getStrutsAction());
    DataObjectModel currentModel = _dataObjectModelManager.getDataObjectModel(modelId);
    assertEquals(currentModel.getId(), new Long(action.getModelId()).longValue());
    assertEquals(currentModel.getShape(), action.getDataObjectShape());
    assertEquals(currentModel.getDataType(), action.getDataType());
    assertEquals(currentModel.getDescription(), action.getDescription());
    assertEquals(currentModel.getStylesheet(), action.getStylesheet());
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 10 with DataObjectModel

use of org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel in project entando-core by entando.

the class TestDataObjectModelFinderAction method createDataObjectModel.

private DataObjectModel createDataObjectModel(int id, String dataType) {
    DataObjectModel model = new DataObjectModel();
    model.setId(id);
    model.setDataType(dataType);
    model.setDescription("Event test Model");
    model.setShape("test shape");
    return model;
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Aggregations

DataObjectModel (org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)24 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)2 RequestContext (com.agiletec.aps.system.RequestContext)1 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringListApiResponse (org.entando.entando.aps.system.services.api.model.StringListApiResponse)1 SmallDataType (org.entando.entando.aps.system.services.dataobject.model.SmallDataType)1 DataObjectRenderizationInfo (org.entando.entando.aps.system.services.dataobjectdispenser.DataObjectRenderizationInfo)1 Cache (org.springframework.cache.Cache)1