*/
public void test04CheckNodeEntities() {
AccessControlTest.clearResourceAccess();
final PropertyMap props = new PropertyMap();
try (final Tx tx = app.tx()) {
List<Class> entityList = Collections.EMPTY_LIST;
try {
entityList = getClasses("org.structr.core.entity");
} catch (IOException | ClassNotFoundException ex) {
logger.log(Level.SEVERE, null, ex);
}
assertTrue(entityList.contains(AbstractNode.class));
assertTrue(entityList.contains(GenericNode.class));
assertTrue(entityList.contains(Location.class));
assertTrue(entityList.contains(Person.class));
assertTrue(entityList.contains(ResourceAccess.class));
assertTrue(entityList.contains(PropertyAccess.class));
// Don't test these, it would fail due to violated constraints
entityList.remove(TestTwo.class);
entityList.remove(TestNine.class);
entityList.remove(MailTemplate.class);
entityList.remove(SchemaNode.class);
for (Class type : entityList) {
// for (Entry<String, Class> entity : entities.entrySet()) {
// Class entityClass = entity.getValue();
if (AbstractNode.class.isAssignableFrom(type)) {
// For TestSeven, fill mandatory fields
if (type.equals(TestSeven.class)) {
props.put(TestSeven.name, "TestSeven-0");
}
// For ResourceAccess, fill mandatory fields
if (type.equals(ResourceAccess.class)) {
props.put(ResourceAccess.signature, "/X");
props.put(ResourceAccess.flags, 6L);
}
// For DynamicResourceAccess, fill mandatory fields
if (type.equals(DynamicResourceAccess.class)) {
props.put(DynamicResourceAccess.signature, "/Y");
props.put(DynamicResourceAccess.flags, 6L);
}
// For PropertyAccess, fill mandatory fields
if (type.equals(PropertyAccess.class)) {
props.put(PropertyAccess.flags, 6L);
}
// For Location, set coordinates
if (type.equals(Location.class)) {
props.put(Location.latitude, 12.34);
props.put(Location.longitude, 56.78);
}
logger.log(Level.INFO, "Creating node of type {0}", type);
NodeInterface node = app.create(type, props);
assertTrue(type.getSimpleName().equals(node.getProperty(AbstractNode.type)));
// Remove mandatory fields for ResourceAccess from props map
if (type.equals(ResourceAccess.class)) {
props.remove(ResourceAccess.signature);
props.remove(ResourceAccess.flags);
}
}
}