use of org.entando.entando.plugins.jacms.aps.system.services.MockContentListBean in project entando-core by entando.
the class TestCacheInfoManager method testGetContents_1.
// ---------------------------------------------- ContentList
public void testGetContents_1() throws Throwable {
try {
UserDetails guestUser = super.getUser(SystemConstants.GUEST_USER_NAME);
MockContentListBean bean = new MockContentListBean();
bean.setContentType("ART");
assertTrue(bean.isCacheable());
String cacheKey = BaseContentListHelper.buildCacheKey(bean, guestUser);
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey));
List<String> contents = this._contentListHelper.getContentsId(bean, guestUser);
assertTrue(contents.size() > 0);
List<String> cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNotNull(cachedContents);
assertEquals(contents.size(), cachedContents.size());
for (int i = 0; i < cachedContents.size(); i++) {
assertEquals(contents.get(i), cachedContents.get(i));
}
} catch (Throwable t) {
throw t;
}
}
use of org.entando.entando.plugins.jacms.aps.system.services.MockContentListBean in project entando-core by entando.
the class TestCacheInfoManager method testGetContentsGroup.
public void testGetContentsGroup() throws Throwable {
try {
UserDetails guestUser = super.getUser(SystemConstants.GUEST_USER_NAME);
MockContentListBean bean = new MockContentListBean();
bean.setContentType("ART");
assertTrue(bean.isCacheable());
String cacheKey = BaseContentListHelper.buildCacheKey(bean, guestUser);
List<String> extractedContents = this._contentListHelper.getContentsId(bean, guestUser);
List<String> cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNotNull(cachedContents);
assertEquals(extractedContents.size(), cachedContents.size());
String cacheGroupId = JacmsSystemConstants.CONTENTS_ID_CACHE_GROUP_PREFIX + "ART";
this._cacheInfoManager.flushGroup(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheGroupId);
cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNull(cachedContents);
extractedContents = this._contentListHelper.getContentsId(bean, guestUser);
cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNotNull(cachedContents);
assertEquals(extractedContents.size(), cachedContents.size());
} catch (Throwable t) {
throw t;
}
}
use of org.entando.entando.plugins.jacms.aps.system.services.MockContentListBean in project entando-core by entando.
the class TestCacheInfoManager method testGetContents_2.
public void testGetContents_2() throws Throwable {
String contentId = null;
try {
UserDetails guestUser = super.getUser(SystemConstants.GUEST_USER_NAME);
MockContentListBean bean = new MockContentListBean();
bean.setContentType("ART");
assertTrue(bean.isCacheable());
String cacheKey = BaseContentListHelper.buildCacheKey(bean, guestUser);
List<String> extractedContents = this._contentListHelper.getContentsId(bean, guestUser);
List<String> cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNotNull(cachedContents);
assertEquals(extractedContents.size(), cachedContents.size());
contentId = this.createMockContent();
super.waitNotifyingThread();
cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNull(cachedContents);
List<String> newExtractedContents = this._contentListHelper.getContentsId(bean, guestUser);
cachedContents = (List<String>) this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, cacheKey);
assertNotNull(cachedContents);
assertEquals(newExtractedContents.size(), cachedContents.size());
assertEquals(newExtractedContents.size(), extractedContents.size() + 1);
for (int i = 0; i < cachedContents.size(); i++) {
assertEquals(newExtractedContents.get(i), cachedContents.get(i));
}
assertTrue(newExtractedContents.contains(contentId));
} catch (Throwable t) {
throw t;
} finally {
this.deleteMockContent(contentId);
}
}
Aggregations