use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestValidateMonotextAttribute method testValidate_MonoListElement.
public void testValidate_MonoListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute("MonoLMonot");
AttributeInterface attribute = monolist.addAttribute();
String formFieldPrefix = "Monolist:" + attribute.getType() + ":";
tracer.setLang(this.getLangManager().getDefaultLang());
tracer.setListIndex(monolist.getAttributes().size() - 1);
tracer.setListLang(this.getLangManager().getDefaultLang());
tracer.setMonoListElement(true);
tracer.setParentAttribute(monolist);
String formFieldName = tracer.getFormFieldName(attribute);
assertEquals(formFieldPrefix + "MonoLMonot_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "MonoLMonotElement0Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = monolist.addAttribute();
tracer.setListIndex(monolist.getAttributes().size() - 1);
String formFieldName2 = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "MonoLMonot_1", formFieldName2);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName2);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestValidateMonotextAttribute method testValidate_ListElement.
public void testValidate_ListElement() throws Throwable {
try {
String contentOnSessionMarker = this.executeCreateNewContent();
Content content = this.getContentOnEdit(contentOnSessionMarker);
AttributeTracer tracer = this.getTracer();
ListAttribute list = (ListAttribute) content.getAttribute("ListMonot");
AttributeInterface attribute = list.addAttribute("it");
assertEquals(0, list.getAttributeList("en").size());
assertEquals(1, list.getAttributeList("it").size());
tracer.setLang(this.getLangManager().getLang("it"));
tracer.setListIndex(list.getAttributeList("it").size() - 1);
tracer.setListLang(this.getLangManager().getLang("it"));
tracer.setListElement(true);
tracer.setParentAttribute(list);
String formFieldName = tracer.getFormFieldName(attribute);
String formFieldPrefix = "List:" + attribute.getType() + ":";
assertEquals(formFieldPrefix + "it_ListMonot_0", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.addParameter(formFieldName, "ListMonotElement0Value");
this.executeAction(Action.INPUT);
this.checkFieldErrors(0, formFieldName);
AttributeInterface attribute2 = list.addAttribute("it");
tracer.setListIndex(list.getAttributes().size() - 1);
formFieldName = tracer.getFormFieldName(attribute2);
assertEquals(formFieldPrefix + "it_ListMonot_1", formFieldName);
this.initSaveContentAction(contentOnSessionMarker);
this.executeAction(Action.INPUT);
this.checkFieldErrors(1, formFieldName);
} catch (Throwable t) {
this.deleteTestContent();
throw t;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentAction method testJoinRemoveGroup.
public void testJoinRemoveGroup() throws Throwable {
String contentId = "ART1";
String contentOnSessionMarker = this.extractSessionMarker(contentId, ApsAdminSystemConstants.EDIT);
this.executeEdit(contentId, "admin");
String groupToAdd = "coach";
String extraGroupFieldName = "extraGroupName";
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(0, contentOnSession.getGroups().size());
this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
this.addParameter(extraGroupFieldName, groupToAdd);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(1, contentOnSession.getGroups().size());
// tentativo aggiunta gruppo duplicata
this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
this.addParameter(extraGroupFieldName, groupToAdd);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(1, contentOnSession.getGroups().size());
// tentativo aggiunta gruppo inesistente
this.initContentAction("/do/jacms/Content", "joinGroup", contentOnSessionMarker);
this.addParameter("contentOnSessionMarker", contentOnSessionMarker);
this.addParameter(extraGroupFieldName, "wrongGroupCode");
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(1, contentOnSession.getGroups().size());
this.initContentAction("/do/jacms/Content", "removeGroup", contentOnSessionMarker);
this.addParameter(extraGroupFieldName, groupToAdd);
result = this.executeAction();
assertEquals(Action.SUCCESS, result);
contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
assertEquals(0, contentOnSession.getGroups().size());
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentAction method testSuccesfullEdit.
private void testSuccesfullEdit(String contentId, String currentUserName) throws Throwable {
Content content = this.getContentManager().loadContent(contentId, false);
String result = this.executeEdit(contentId, currentUserName);
assertEquals(Action.SUCCESS, result);
try {
String contentSessionMarker = AbstractContentAction.buildContentOnSessionMarker(content, ApsAdminSystemConstants.EDIT);
Content currentContent = this.getContentOnEdit(contentSessionMarker);
assertEquals(content.getId(), currentContent.getId());
assertEquals(content.getTypeCode(), currentContent.getTypeCode());
assertEquals(content.getDescription(), currentContent.getDescription());
assertEquals(content.getMainGroup(), currentContent.getMainGroup());
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentAction method testSuspendReferencedContent.
public void testSuspendReferencedContent() throws Throwable {
String contentId = "ART1";
Content master = this.getContentManager().loadContent(contentId, false);
String contentOnSessionMarker = AbstractContentAction.buildContentOnSessionMarker(master, ApsAdminSystemConstants.EDIT);
try {
this.executeEdit(contentId, "admin");
Content contentOnSession = this.getContentOnEdit(contentOnSessionMarker);
assertNotNull(contentOnSession);
this.initContentAction("/do/jacms/Content", "suspend", contentOnSessionMarker);
String result = this.executeAction();
assertEquals("references", result);
ContentAction action = (ContentAction) this.getAction();
List contentUtilizers = (List) action.getReferences().get("jacmsContentManagerUtilizers");
assertEquals(2, contentUtilizers.size());
List pageUtilizers = (List) action.getReferences().get("CmsPageManagerWrapperUtilizers");
assertEquals(1, pageUtilizers.size());
IPage publicPageUtilizer = (IPage) pageUtilizers.get(0);
assertEquals("homepage", publicPageUtilizer.getCode());
assertTrue(publicPageUtilizer.isOnlineInstance());
} catch (Throwable t) {
this.getContentManager().insertOnLineContent(master);
throw t;
}
}
Aggregations