use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentEntityManager method testLoadOrderedEvents_1.
public void testLoadOrderedEvents_1() throws ApsSystemException {
EntitySearchFilter filterForDescr = new EntitySearchFilter(IContentManager.CONTENT_DESCR_FILTER_KEY, false);
filterForDescr.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filterForDescr };
List<String> contents = _contentManager.searchId("EVN", filters);
String[] expectedContentsId = { "EVN24", "EVN23", "EVN103", "EVN191", "EVN192", "EVN193", "EVN194", "EVN41", "EVN20", "EVN21", "EVN25" };
assertEquals(expectedContentsId.length, contents.size());
for (int i = 0; i < expectedContentsId.length; i++) {
assertEquals(expectedContentsId[i], contents.get(i));
}
filterForDescr.setOrder(EntitySearchFilter.DESC_ORDER);
contents = _contentManager.searchId("EVN", filters);
assertEquals(expectedContentsId.length, contents.size());
for (int i = 0; i < expectedContentsId.length; i++) {
assertEquals(expectedContentsId[expectedContentsId.length - i - 1], contents.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestContentListHelper method testGetContents_1.
public void testGetContents_1() throws Throwable {
String pageCode = "pagina_1";
int frame = 1;
try {
this.setUserOnSession("guest");
RequestContext reqCtx = this.valueRequestContext(pageCode, frame);
MockContentListTagBean bean = new MockContentListTagBean();
bean.setContentType("EVN");
EntitySearchFilter filter = new EntitySearchFilter("DataInizio", true);
filter.setOrder(EntitySearchFilter.DESC_ORDER);
bean.addFilter(filter);
List<String> contents = this._helper.getContentsId(bean, reqCtx);
String[] expected = { "EVN194", "EVN193", "EVN24", "EVN23", "EVN25", "EVN20", "EVN21", "EVN192", "EVN191" };
assertEquals(expected.length, contents.size());
for (int i = 0; i < expected.length; i++) {
assertEquals(expected[i], contents.get(i));
}
} catch (Throwable t) {
throw t;
} finally {
this.setPageWidgets(pageCode, frame, null);
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testSearchDataObjects_3.
public void testSearchDataObjects_3() throws Throwable {
EntitySearchFilter modifyOrder = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_MODIFY_DATE_FILTER_KEY, false);
modifyOrder.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter onlineFilter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_ONLINE_FILTER_KEY, false, "encoding=", true);
EntitySearchFilter[] filters = { modifyOrder, onlineFilter };
List<String> dataObjectIds = this._dataObjectManager.searchId(filters);
assertNotNull(dataObjectIds);
String[] expected = { "ART187", "ART1", "EVN193", "EVN194", "ART180", "RAH1", "EVN191", "EVN192", "RAH101", "EVN103", "ART104", "ART102", "EVN23", "EVN24", "EVN25", "EVN41", "EVN20", "EVN21", "ART111", "ART120", "ART121", "ART122", "ART112", "ALL4" };
assertEquals(expected.length, dataObjectIds.size());
this.verifyOrder(dataObjectIds, expected);
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadEvents_1_b.
public void testLoadEvents_1_b() throws ApsSystemException {
// forcing case insensitive search
DataObjectSearcherDAO searcherDao = (DataObjectSearcherDAO) this.getApplicationContext().getBean("DataObjectSearcherDAO");
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
List<String> allowedDescription = new ArrayList<String>();
// "ART179" "ART180" "ART187"
allowedDescription.add("descrizione");
// "ART179"
allowedDescription.add("on line");
// "ART102" "RAH101"
allowedDescription.add("customers");
EntitySearchFilter filter = new EntitySearchFilter(IDataObjectManager.DATA_OBJECT_DESCR_FILTER_KEY, false, allowedDescription, true);
EntitySearchFilter filter2 = new EntitySearchFilter(IDataObjectManager.ENTITY_ID_FILTER_KEY, false);
filter2.setOrder(EntitySearchFilter.ASC_ORDER);
EntitySearchFilter[] filters = { filter, filter2 };
List<String> dataObjects = _dataObjectManager.loadDataObjectsId(null, filters, groups);
String[] expectedOrderedDataObjectsId2 = { "ART102", "ART180", "ART187", "RAH101" };
assertEquals(expectedOrderedDataObjectsId2.length, dataObjects.size());
for (int i = 0; i < expectedOrderedDataObjectsId2.length; i++) {
assertEquals(expectedOrderedDataObjectsId2[i], dataObjects.get(i));
}
}
use of com.agiletec.aps.system.common.entity.model.EntitySearchFilter in project entando-core by entando.
the class TestDataObjectManager method testLoadDataObjectsForCategory_2.
public void testLoadDataObjectsForCategory_2() throws ApsSystemException {
List<String> groups = new ArrayList<String>();
groups.add(Group.ADMINS_GROUP_NAME);
String[] categories1 = { "general_cat1" };
EntitySearchFilter filter1 = new EntitySearchFilter(IDataObjectManager.ENTITY_TYPE_CODE_FILTER_KEY, false, "ART", false);
EntitySearchFilter[] filters = { filter1 };
List<String> dataObjects = this._dataObjectManager.loadDataObjectsId(categories1, filters, groups);
assertEquals(2, dataObjects.size());
assertTrue(dataObjects.contains("ART102"));
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART180"));
// assertTrue(dataObjects.contains("ART179"));
String[] categories2 = { "general_cat2" };
dataObjects = this._dataObjectManager.loadDataObjectsId(categories2, filters, groups);
assertEquals(2, dataObjects.size());
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART112"));
assertTrue(dataObjects.contains("ART120"));
// assertTrue(dataObjects.contains("ART179"));
String[] categories12 = { "general_cat1", "general_cat2" };
dataObjects = this._dataObjectManager.loadDataObjectsId(categories12, false, filters, groups);
assertEquals(1, dataObjects.size());
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART179"));
dataObjects = this._dataObjectManager.loadDataObjectsId(categories12, true, filters, groups);
assertEquals(3, dataObjects.size());
assertTrue(dataObjects.contains("ART102"));
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART112"));
assertTrue(dataObjects.contains("ART120"));
// assertTrue(dataObjects.contains("ART180"));
String[] categories3 = { "general_cat3" };
dataObjects = this._dataObjectManager.loadDataObjectsId(categories3, filters, groups);
assertEquals(2, dataObjects.size());
assertTrue(dataObjects.contains("ART120"));
// assertTrue(dataObjects.contains("ART121"));
assertTrue(dataObjects.contains("ART122"));
String[] categories23 = { "general_cat2", "general_cat3" };
dataObjects = this._dataObjectManager.loadDataObjectsId(categories23, false, filters, groups);
assertEquals(1, dataObjects.size());
assertTrue(dataObjects.contains("ART120"));
dataObjects = this._dataObjectManager.loadDataObjectsId(categories23, true, filters, groups);
assertEquals(3, dataObjects.size());
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART112"));
assertTrue(dataObjects.contains("ART120"));
// assertTrue(dataObjects.contains("ART179"));
// assertTrue(dataObjects.contains("ART121"));
assertTrue(dataObjects.contains("ART122"));
String[] categories123 = { "general_cat1", "general_cat2", "general_cat3" };
dataObjects = this._dataObjectManager.loadDataObjectsId(categories123, false, filters, groups);
assertEquals(0, dataObjects.size());
dataObjects = this._dataObjectManager.loadDataObjectsId(categories123, true, filters, groups);
assertEquals(4, dataObjects.size());
assertTrue(dataObjects.contains("ART102"));
assertTrue(dataObjects.contains("ART111"));
// assertTrue(dataObjects.contains("ART112"));
assertTrue(dataObjects.contains("ART120"));
// assertTrue(dataObjects.contains("ART121"));
assertTrue(dataObjects.contains("ART122"));
// assertTrue(dataObjects.contains("ART180"));
// assertTrue(dataObjects.contains("ART179"));
}
Aggregations