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