Search in sources :

Example 21 with DataObjectModel

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

the class TestDataObjectModelAction method testDeleteModel.

public void testDeleteModel() 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", "delete");
        this.addParameter("modelId", String.valueOf(modelId));
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        model = this._dataObjectModelManager.getDataObjectModel(modelId);
        assertNull(model);
        eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
        assertEquals(0, eventModels.size());
    } catch (Throwable t) {
        model = this._dataObjectModelManager.getDataObjectModel(modelId);
        if (null != model) {
            this._dataObjectModelManager.removeDataObjectModel(model);
        }
        eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
        assertEquals(0, eventModels.size());
        throw t;
    }
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 22 with DataObjectModel

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

the class TestDataObjectModelAction method testAddNewModel.

public void testAddNewModel() throws Throwable {
    List<DataObjectModel> eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
    assertEquals(0, eventModels.size());
    long modelIdToAdd = 99;
    try {
        this.setUserOnSession("admin");
        this.initAction("/do/dataobject/model", "save");
        addParameter("dataType", "EVN");
        addParameter("strutsAction", new Integer(ApsAdminSystemConstants.ADD).toString());
        addParameter("description", "dataObjectModel description");
        addParameter("dataObjectShape", "dataObjectShape field value\r\n");
        addParameter("modelId", String.valueOf(modelIdToAdd));
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        eventModels = this._dataObjectModelManager.getModelsForDataObjectType("EVN");
        assertEquals(1, eventModels.size());
        DataObjectModel model = eventModels.get(0);
        assertEquals("dataObjectShape field value\r\n", model.getShape());
    } catch (Throwable t) {
        throw t;
    } finally {
        DataObjectModel model = this._dataObjectModelManager.getDataObjectModel(modelIdToAdd);
        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 23 with DataObjectModel

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

the class TestDataObjectModelFinderAction method tearDown.

@Override
protected void tearDown() throws Exception {
    super.tearDown();
    DataObjectModel model = this._dataObjectModelManager.getDataObjectModel(MODEL_ID);
    if (null != model) {
        this._dataObjectModelManager.removeDataObjectModel(model);
    }
}
Also used : DataObjectModel(org.entando.entando.aps.system.services.dataobjectmodel.DataObjectModel)

Example 24 with DataObjectModel

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

the class TestDataObjectModelFinderAction method testSearch_2.

public void testSearch_2() throws Throwable {
    DataObjectModel dataObjectModel = this.createDataObjectModel(MODEL_ID, "EVN");
    this._dataObjectModelManager.addDataObjectModel(dataObjectModel);
    String result = this.executeSearch("");
    assertEquals(Action.SUCCESS, result);
    DataObjectModelFinderAction dataObjectModelFinderAction = (DataObjectModelFinderAction) this.getAction();
    List<DataObjectModel> dataObjectModels = dataObjectModelFinderAction.getDataObjectModels();
    assertEquals(5, dataObjectModels.size());
    result = this.executeSearch("EVN");
    assertEquals(Action.SUCCESS, result);
    dataObjectModelFinderAction = (DataObjectModelFinderAction) this.getAction();
    dataObjectModels = dataObjectModelFinderAction.getDataObjectModels();
    assertEquals(1, dataObjectModels.size());
}
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