use of org.structr.core.property.PropertyMap in project structr by structr.
the class DeploymentTest method test37SharedComponentTemplate.
@Test
public void test37SharedComponentTemplate() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createSimplePage(securityContext, "page1");
final Div div = (Div) page.getElementsByTagName("div").item(0);
try {
final DOMNode newNode = (DOMNode) page.createTextNode("#template");
newNode.unlockSystemPropertiesOnce();
newNode.setProperties(newNode.getSecurityContext(), new PropertyMap(NodeInterface.type, Template.class.getSimpleName()));
// append template
div.appendChild(newNode);
// create component from div
createComponent(div);
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception.");
}
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.core.property.PropertyMap in project structr by structr.
the class DeploymentTest method test11TemplateInTbody.
@Test
public void test11TemplateInTbody() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page1 = Page.createNewPage(securityContext, "test11");
final Html html1 = createElement(page1, page1, "html");
final Head head1 = createElement(page1, html1, "head");
createElement(page1, head1, "title", "test11_1");
final Body body1 = createElement(page1, html1, "body");
final Table table = createElement(page1, body1, "table");
final Tbody tbody = createElement(page1, table, "tbody");
final Template template1 = createTemplate(page1, tbody, "<tr><td>${user.name}</td></tr>");
final PropertyMap template1Properties = new PropertyMap();
template1Properties.put(StructrApp.key(DOMNode.class, "functionQuery"), "find('User')");
template1Properties.put(StructrApp.key(DOMNode.class, "dataKey"), "user");
template1.setProperties(template1.getSecurityContext(), template1Properties);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.core.property.PropertyMap in project structr by structr.
the class DeploymentTest method test04ContentTypes.
@Test
public void test04ContentTypes() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test04");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test04");
createElement(page, head, "link");
createElement(page, head, "link");
createComment(page, head, "commentöäüÖÄÜß+#");
final Link link3 = createElement(page, head, "link");
final PropertyMap link3Properties = new PropertyMap();
link3Properties.put(StructrApp.key(Link.class, "_html_href"), "/");
link3Properties.put(StructrApp.key(Link.class, "_html_media"), "screen");
link3Properties.put(StructrApp.key(Link.class, "_html_type"), "stylesheet");
link3.setProperties(link3.getSecurityContext(), link3Properties);
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
createElement(page, div1, "h1", "private");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
use of org.structr.core.property.PropertyMap in project structr by structr.
the class AdvancedSchemaTest method test03InheritanceOfFileAttributesToSubclassOfImage.
@Test
public void test03InheritanceOfFileAttributesToSubclassOfImage() {
try (final Tx tx = app.tx()) {
createAdminUser();
createResourceAccess("_schema", UiAuthenticator.AUTH_USER_GET);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
SchemaNode fileNodeDef = app.nodeQuery(SchemaNode.class).andName("File").getFirst();
SchemaProperty testFileProperty = app.create(SchemaProperty.class);
final PropertyMap testFileProperties = new PropertyMap();
testFileProperties.put(SchemaProperty.name, "testFile");
testFileProperties.put(SchemaProperty.propertyType, "String");
testFileProperties.put(SchemaProperty.schemaNode, fileNodeDef);
testFileProperty.setProperties(testFileProperty.getSecurityContext(), testFileProperties);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
// Create new schema node for dynamic class SubFile which extends File
SchemaNode subFile = app.create(SchemaNode.class);
final PropertyMap subFileProperties = new PropertyMap();
subFileProperties.put(SchemaNode.name, "SubFile");
subFileProperties.put(SchemaNode.extendsClass, "org.structr.dynamic.Image");
subFile.setProperties(subFile.getSecurityContext(), subFileProperties);
// Add String property "testSubFile" to new dynamic class
SchemaProperty testFileProperty = app.create(SchemaProperty.class);
final PropertyMap testFileProperties = new PropertyMap();
testFileProperties.put(SchemaProperty.name, "testSubFile");
testFileProperties.put(SchemaProperty.propertyType, "String");
testFileProperties.put(SchemaProperty.schemaNode, subFile);
testFileProperty.setProperties(testFileProperty.getSecurityContext(), testFileProperties);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
RestAssured.given().contentType("application/json; charset=UTF-8").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(201)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(400)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(404)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(422)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(500)).headers("X-User", ADMIN_USERNAME, "X-Password", ADMIN_PASSWORD).expect().statusCode(200).body("result", hasSize(count2 + 1)).body("result", Matchers.hasItem(Matchers.allOf(hasEntry("jsonName", "testFile"), hasEntry("declaringClass", "File")))).body("result", Matchers.hasItem(Matchers.allOf(hasEntry("jsonName", "testSubFile"), hasEntry("declaringClass", "SubFile")))).when().get("/_schema/SubFile/ui");
tx.success();
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.property.PropertyMap in project structr by structr.
the class AdvancedSchemaTest method test02InheritanceOfFileAttributesToSubclass.
@Test
public void test02InheritanceOfFileAttributesToSubclass() {
try (final Tx tx = app.tx()) {
createAdminUser();
createResourceAccess("_schema", UiAuthenticator.AUTH_USER_GET);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
SchemaNode fileNodeDef = app.nodeQuery(SchemaNode.class).andName("File").getFirst();
SchemaProperty testFileProperty = app.create(SchemaProperty.class);
final PropertyMap changedProperties = new PropertyMap();
changedProperties.put(SchemaProperty.name, "testFile");
changedProperties.put(SchemaProperty.propertyType, "String");
changedProperties.put(SchemaProperty.schemaNode, fileNodeDef);
testFileProperty.setProperties(testFileProperty.getSecurityContext(), changedProperties);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
// Create new schema node for dynamic class SubFile which extends File
SchemaNode subFile = app.create(SchemaNode.class);
final PropertyMap subFileProperties = new PropertyMap();
subFileProperties.put(SchemaNode.name, "SubFile");
subFileProperties.put(SchemaNode.extendsClass, "org.structr.dynamic.File");
subFile.setProperties(subFile.getSecurityContext(), subFileProperties);
// Add String property "testSubFile" to new dynamic class
SchemaProperty testFileProperty = app.create(SchemaProperty.class);
final PropertyMap testFileProperties = new PropertyMap();
testFileProperties.put(SchemaProperty.name, "testSubFile");
testFileProperties.put(SchemaProperty.propertyType, "String");
testFileProperties.put(SchemaProperty.schemaNode, subFile);
testFileProperty.setProperties(testFileProperty.getSecurityContext(), testFileProperties);
tx.success();
} catch (Exception ex) {
logger.error("", ex);
}
try (final Tx tx = app.tx()) {
RestAssured.given().contentType("application/json; charset=UTF-8").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(201)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(400)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(404)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(422)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(500)).headers("X-User", ADMIN_USERNAME, "X-Password", ADMIN_PASSWORD).expect().statusCode(200).body("result", hasSize(count1 + 1)).body("result", Matchers.hasItem(Matchers.allOf(hasEntry("jsonName", "testFile"), hasEntry("declaringClass", "File")))).body("result", Matchers.hasItem(Matchers.allOf(hasEntry("jsonName", "testSubFile"), hasEntry("declaringClass", "SubFile")))).when().get("/_schema/SubFile/ui");
tx.success();
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
Aggregations