use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class TestEntityManagersAction method testInitEditEntityType.
public void testInitEditEntityType() throws Throwable {
String[] defNames = this.getApplicationContext().getBeanNamesForType(ApsEntityManager.class);
if (null == defNames || defNames.length == 0)
return;
String entityManagerName = defNames[0];
IEntityManager entityManager = (IEntityManager) this.getApplicationContext().getBean(entityManagerName);
Map<String, IApsEntity> entityPrototypes = entityManager.getEntityPrototypes();
if (null == entityPrototypes || entityPrototypes.size() == 0)
return;
IApsEntity realEntityPrototype = new ArrayList<IApsEntity>(entityPrototypes.values()).get(0);
String result = this.executeInitEditEntityType("supervisorCoach", entityManagerName, realEntityPrototype.getTypeCode());
assertEquals("userNotAllowed", result);
result = this.executeInitEditEntityType("admin", null, realEntityPrototype.getTypeCode());
assertEquals(Action.INPUT, result);
assertEquals(1, this.getAction().getFieldErrors().size());
assertEquals(1, this.getAction().getFieldErrors().get("entityManagerName").size());
if (null == entityPrototypes.get("XXX")) {
result = this.executeInitEditEntityType("admin", entityManagerName, "XXX");
assertEquals("wrongEntityType", result);
assertEquals(1, this.getAction().getFieldErrors().size());
assertEquals(1, this.getAction().getFieldErrors().get("entityTypeCode").size());
}
result = this.executeInitEditEntityType("admin", entityManagerName, null);
assertEquals("wrongEntityType", result);
assertEquals(1, this.getAction().getFieldErrors().size());
assertEquals(1, this.getAction().getFieldErrors().get("entityTypeCode").size());
result = this.executeInitEditEntityType("admin", entityManagerName, realEntityPrototype.getTypeCode());
assertEquals(Action.SUCCESS, result);
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class TestEntityManagersAction method executeEditAttribute.
private String executeEditAttribute(String username, String attributeName, String entityTypeCode, String entityManagerName) throws Throwable {
this.setUserOnSession(username);
this.initAction("/do/Entity/Attribute", "editAttribute");
this.addParameter("attributeName", attributeName);
IEntityManager entityManager = (IEntityManager) this.getApplicationContext().getBean(entityManagerName);
IApsEntity entityType = entityManager.getEntityPrototype(entityTypeCode);
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM, entityType);
return this.executeAction();
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class TestJacmsEntityManagersAction method addEntityTypeForTest.
private void addEntityTypeForTest(String typeCode, String typeDescr) throws Throwable {
assertNull(this._contentManager.getEntityPrototype(typeCode));
IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
prototype.setTypeCode(typeCode);
prototype.setTypeDescr(typeDescr);
((IEntityTypesConfigurer) this._contentManager).addEntityPrototype(prototype);
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class TestJacmsEntityManagersAction method testGetEntityPrototypes.
public void testGetEntityPrototypes() throws Throwable {
String result = this.executeViewModels(JacmsSystemConstants.CONTENT_MANAGER);
assertEquals(Action.SUCCESS, result);
IEntityTypesAction action = (IEntityTypesAction) this.getAction();
List<IApsEntity> entityPrototypes = action.getEntityPrototypes();
assertNotNull(entityPrototypes);
assertEquals(4, entityPrototypes.size());
IApsEntity firstType = entityPrototypes.get(0);
assertEquals("ART", firstType.getTypeCode());
assertEquals("Articolo rassegna stampa", firstType.getTypeDescr());
IApsEntity lastType = entityPrototypes.get(3);
assertEquals("RAH", lastType.getTypeCode());
assertEquals("Tipo_Semplice", lastType.getTypeDescr());
}
use of com.agiletec.aps.system.common.entity.model.IApsEntity in project entando-core by entando.
the class TestJacmsEntityTypeConfigAction method testSaveEntityType.
public void testSaveEntityType() throws Throwable {
String typeCode = "TST";
assertNull(this._contentManager.getEntityPrototype(typeCode));
try {
IApsEntity prototype = this._contentManager.getEntityPrototype("ART");
prototype.setTypeCode(typeCode);
prototype.setTypeDescr("Entity type Description");
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_MANAGER_SESSION_PARAM, JacmsSystemConstants.CONTENT_MANAGER);
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_OPERATION_ID_SESSION_PARAM, new Integer(ApsAdminSystemConstants.ADD));
this.getRequest().getSession().setAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM, prototype);
String result = this.executeSaveEntityType(prototype.getTypeCode(), prototype.getTypeDescr());
assertEquals(Action.SUCCESS, result);
assertNotNull(this._contentManager.getEntityPrototype(typeCode));
assertNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
result = this.executeEditEntityPrototype(typeCode, JacmsSystemConstants.CONTENT_MANAGER);
assertEquals(Action.SUCCESS, result);
assertNotNull(this.getRequest().getSession().getAttribute(IEntityTypeConfigAction.ENTITY_TYPE_ON_EDIT_SESSION_PARAM));
} catch (Throwable t) {
throw t;
} finally {
if (null != this._contentManager.getEntityPrototype(typeCode)) {
((IEntityTypesConfigurer) this._contentManager).removeEntityPrototype(typeCode);
}
}
}
Aggregations