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());
}
}
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);
}
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);
}
}
}
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());
}
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;
}
Aggregations