use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class TestValidateDataObject 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 {
DataObject content = this.createNewVoid("RAH", "descr", DataObject.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 org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class TestDataObjectAuthorization method testCheckCustomerUser.
public void testCheckCustomerUser() throws Throwable {
UserDetails extractedUser = this.getUser("pageManagerCustomers");
assertNotNull(extractedUser);
assertEquals("pageManagerCustomers", extractedUser.getUsername());
assertEquals(1, extractedUser.getAuthorizations().size());
IDataObjectManager contentManager = (IDataObjectManager) this.getService("DataObjectManager");
DataObject content = contentManager.loadDataObject("ART111", true);
boolean checkContent = this._authorizationManager.isAuth(extractedUser, content);
assertTrue(checkContent);
content = contentManager.loadDataObject("EVN25", true);
checkContent = this._authorizationManager.isAuth(extractedUser, content);
assertTrue(checkContent);
content = contentManager.loadDataObject("EVN41", true);
checkContent = this._authorizationManager.isAuth(extractedUser, content);
assertFalse(checkContent);
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class TestDataObjectDispenser method testGetRenderedContent_3.
public void testGetRenderedContent_3() throws Throwable {
DataObject dataobject = this._dataObjectManager.loadDataObject("ART120", true);
dataobject.setId(null);
try {
RequestContext reqCtx = this.getRequestContext();
this.setUserOnSession("admin");
this._dataObjectManager.insertDataObject(dataobject);
DataObjectRenderizationInfo outputInfo = this._dataObjectDispenser.getRenderizationInfo(dataobject.getId(), 2, "it", reqCtx);
assertNotNull(outputInfo);
// assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
// assertNotNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
this._dataObjectManager.insertDataObject(dataobject);
this.waitNotifyingThread();
// assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_CACHE_PREFIX+dataobject.getId()));
// assertNull(this._cacheInfoManager.getFromCache(JacmsSystemConstants.CONTENT_AUTH_INFO_CACHE_PREFIX+dataobject.getId()));
} catch (Throwable t) {
throw t;
} finally {
if (null != dataobject.getId()) {
this._dataObjectManager.deleteDataObject(dataobject);
}
}
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class TestSearchEngineManager method createDataObject_1.
private DataObject createDataObject_1() {
DataObject content = new DataObject();
content.setId("100");
content.setMainGroup(Group.FREE_GROUP_NAME);
content.addGroup("secondaryGroup");
content.setTypeCode("ART");
TextAttribute text = new TextAttribute();
text.setName("Articolo");
text.setType("Text");
text.setIndexingType(IndexableAttributeInterface.INDEXING_TYPE_TEXT);
text.setText("San Pietroburgo è una città meravigliosa W3C-WAI", "it");
text.setText("St. Petersburg is a wonderful city", "en");
content.addAttribute(text);
Category category1 = this._categoryManager.getCategory("resCat2");
Category category2 = this._categoryManager.getCategory("general_cat3");
content.addCategory(category1);
content.addCategory(category2);
return content;
}
use of org.entando.entando.aps.system.services.dataobject.model.DataObject in project entando-core by entando.
the class TestSearchEngineManager method testSearchContentsId_1.
public void testSearchContentsId_1() throws Throwable {
try {
DataObject content_1 = this.createDataObject_1();
this.dataObjectSearchEngineManager.deleteIndexedEntity(content_1.getId());
this.dataObjectSearchEngineManager.addEntityToIndex(content_1);
DataObject content_2 = this.createDataObject_2();
this.dataObjectSearchEngineManager.deleteIndexedEntity(content_2.getId());
this.dataObjectSearchEngineManager.addEntityToIndex(content_2);
List<String> contentsId = this.dataObjectSearchEngineManager.searchEntityId("it", "San meravigliosa", null);
assertNotNull(contentsId);
assertTrue(contentsId.contains(content_1.getId()));
contentsId = this.dataObjectSearchEngineManager.searchEntityId("en", "Petersburg wonderful", null);
assertNotNull(contentsId);
assertTrue(contentsId.contains(content_1.getId()));
contentsId = this.dataObjectSearchEngineManager.searchEntityId("en", "meravigliosa", null);
assertNotNull(contentsId);
assertFalse(contentsId.contains(content_1.getId()));
} catch (Throwable t) {
throw t;
}
}
Aggregations