use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentManager method testSearchWorkContents_3.
public void testSearchWorkContents_3() throws Throwable {
List<String> groupCodes = new ArrayList<String>();
groupCodes.add(Group.ADMINS_GROUP_NAME);
EntitySearchFilter creationOrder = new EntitySearchFilter(IContentManager.CONTENT_CREATION_DATE_FILTER_KEY, false);
creationOrder.setOrder(EntitySearchFilter.DESC_ORDER);
EntitySearchFilter[] filters = { creationOrder };
String[] categories_1 = { "general_cat2" };
List<String> contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_a = { "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_a.length, contents.size());
this.verifyOrder(contents, order_a);
String[] categories_2 = { "general_cat1", "general_cat2" };
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_b = { "ART111", "ART179" };
assertEquals(order_b.length, contents.size());
assertEquals(order_b[0], contents.get(0));
Content newContent = this._contentManager.loadContent("EVN193", false);
newContent.setId(null);
try {
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_1, filters, groupCodes);
String[] order_c = { newContent.getId(), "ART120", "ART112", "ART111", "EVN193", "ART179" };
assertEquals(order_c.length, contents.size());
this.verifyOrder(contents, order_c);
ICategoryManager categoryManager = (ICategoryManager) this.getService(SystemConstants.CATEGORY_MANAGER);
newContent.addCategory(categoryManager.getCategory("general_cat1"));
this._contentManager.saveContent(newContent);
contents = this._contentManager.loadWorkContentsId(categories_2, filters, groupCodes);
String[] order_d = { newContent.getId(), "ART111", "ART179" };
assertEquals(order_d.length, contents.size());
this.verifyOrder(contents, order_d);
} catch (Throwable t) {
throw t;
} finally {
this._contentManager.deleteContent(newContent);
assertNull(this._contentManager.loadContent(newContent.getId(), false));
}
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentManager method addDraftContentsForTest.
protected String[] addDraftContentsForTest(String[] masterContentIds, boolean publish) throws Throwable {
String[] newContentIds = new String[masterContentIds.length];
for (int i = 0; i < masterContentIds.length; i++) {
Content content = this._contentManager.loadContent(masterContentIds[i], false);
content.setId(null);
this._contentManager.saveContent(content);
newContentIds[i] = content.getId();
if (publish) {
this._contentManager.insertOnLineContent(content);
}
}
for (int i = 0; i < newContentIds.length; i++) {
Content content = this._contentManager.loadContent(newContentIds[i], false);
assertNotNull(content);
}
return newContentIds;
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestContentManager method testCreateContentWithViewPage.
public void testCreateContentWithViewPage() {
Content content = _contentManager.createContentType("ART");
String viewPage = content.getViewPage();
assertEquals(viewPage, "contentview");
}
use of com.agiletec.plugins.jacms.aps.system.services.content.model.Content in project entando-core by entando.
the class TestValidateContent method testValidate_4.
public void testValidate_4() throws Throwable {
String shortTitle = "short";
String longTitle = "Titolo che supera la lunghezza massima di cento caratteri; " + "Ripeto, Titolo che supera la lunghezza massima di cento caratteri";
try {
Content content = this.createNewVoid("RAH", "descr", Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
ITextAttribute textAttribute = (ITextAttribute) content.getAttribute("Titolo");
textAttribute.setText(shortTitle, "it");
List<FieldError> errors = content.validate(this._groupManager);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
textAttribute.setText(longTitle, "it");
errors = content.validate(this._groupManager);
assertEquals(1, errors.size());
error = errors.get(0);
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
textAttribute.setText(shortTitle, "en");
errors = content.validate(this._groupManager);
assertEquals(2, errors.size());
error = errors.get(0);
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.INVALID_MAX_LENGTH, error.getErrorCode());
error = errors.get(1);
assertEquals("Text:en_Titolo", error.getFieldCode());
assertEquals(FieldError.INVALID_MIN_LENGTH, error.getErrorCode());
} 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 TestValidateContent method testValidate_1.
public void testValidate_1() throws Throwable {
String insertedDescr = "XXX Prova Validazione XXX";
try {
Content content = this.createNewVoid("ART", insertedDescr, Content.STATUS_DRAFT, Group.FREE_GROUP_NAME, "admin");
List<FieldError> errors = content.validate(this._groupManager);
assertNotNull(errors);
assertEquals(1, errors.size());
FieldError error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
String monolistAttributeName = "Autori";
MonoListAttribute monolist = (MonoListAttribute) content.getAttribute(monolistAttributeName);
monolist.addAttribute();
assertEquals(1, monolist.getAttributes().size());
errors = content.validate(this._groupManager);
assertEquals(2, errors.size());
error = errors.get(0);
// Verifica obbligatorietĂ attributo "Titolo"
assertEquals("Text:it_Titolo", error.getFieldCode());
assertEquals(FieldError.MANDATORY, error.getErrorCode());
error = errors.get(1);
// Verifica non valido elemento 1 in attributo lista "Autori"
assertEquals("Monolist:Monotext:Autori_0", error.getFieldCode());
assertEquals(FieldError.INVALID, error.getErrorCode());
} catch (Throwable t) {
throw t;
}
}
Aggregations