use of org.structr.web.entity.html.Html in project structr by structr.
the class DeploymentTest method test18NonNamedNonSharedTemplateWithChildren.
@Test
public void test18NonNamedNonSharedTemplateWithChildren() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test18");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test18");
final Body body = createElement(page, html, "body");
final Template template = createTemplate(page, body, "${render(children)}");
final Template sharedTemplate = createComponent(template);
// remove original template from page
app.delete(template);
createElement(page, sharedTemplate, "div");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true, false);
}
use of org.structr.web.entity.html.Html in project structr by structr.
the class DeploymentTest method test31RoundtripWithEmptyContentElements.
@Test
public void test31RoundtripWithEmptyContentElements() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test31");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test31");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Div div2 = createElement(page, div1, "div", "");
final Table table1 = createElement(page, div2, "table");
final Thead thead = createElement(page, table1, "thead");
final Tbody tbody = createElement(page, table1, "tbody");
final Tr tr1 = createElement(page, thead, "tr");
final Tr tr2 = createElement(page, tbody, "tr");
final Td td11 = createElement(page, tr1, "td");
final Content c1 = createContent(page, td11, "");
final Td td12 = createElement(page, tr1, "td", "content12");
final P p1 = createElement(page, td12, "p", "");
final Ul ul = createElement(page, p1, "ul");
final Li li = createElement(page, ul, "li", "");
final Td td21 = createElement(page, tr2, "td", "content21");
final Td td22 = createElement(page, tr2, "td", "content22");
final Select select = createElement(page, td11, "select");
final Option option1 = createElement(page, select, "option", "");
final Option option2 = createElement(page, select, "option", "value2");
final Content c2 = createContent(page, div2, "");
final Table table2 = createElement(page, div2, "table");
// include visibility flags
page.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
c1.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
c2.setProperty(AbstractNode.visibleToAuthenticatedUsers, true);
// modify visibility to produce two consecutive deployment instruction comments
td12.setProperty(AbstractNode.visibleToPublicUsers, true);
table2.setProperty(AbstractNode.visibleToPublicUsers, true);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Html in project structr by structr.
the class DeploymentTest method test35WidgetWithSharedComponentCreation.
@Test
public void test35WidgetWithSharedComponentCreation() {
// setup
try (final Tx tx = app.tx()) {
final Page testPage = Page.createNewPage(securityContext, "WidgetTestPage");
final Html html = createElement(testPage, testPage, "html");
final Head head = createElement(testPage, html, "head");
final Body body = createElement(testPage, html, "body");
final Div div = createElement(testPage, body, "div");
final Div div2 = createElement(testPage, body, "div");
div.setProperty(AbstractNode.name, "WidgetTestPage-Div");
div2.setProperty(AbstractNode.name, "WidgetTestPage-Div2");
Widget widgetToImport = app.create(Widget.class, new NodeAttribute<>(StructrApp.key(Widget.class, "name"), "TestWidget"), new NodeAttribute<>(StructrApp.key(Widget.class, "source"), "<structr:component src=\"TestComponent\">\n" + " <div data-structr-meta-name=\"TestComponent\">\n" + " Test123\n" + " </div>\n" + "</structr:component>"), new NodeAttribute<>(StructrApp.key(Widget.class, "configuration"), ""), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToPublicUsers"), true), new NodeAttribute<>(StructrApp.key(Widget.class, "visibleToAuthenticatedUsers"), true));
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("widgetHostBaseUrl", "https://widgets.structr.org/structr/rest/widgets");
paramMap.put("parentId", widgetToImport.getProperty(new StartNode<>("owner", PrincipalOwnsNode.class)));
paramMap.put("source", widgetToImport.getProperty(new StringProperty("source")));
paramMap.put("processDeploymentInfo", false);
Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
Widget.expandWidget(securityContext, testPage, div, baseUri, paramMap, false);
makePublic(testPage, html, head, body, div, div2);
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
// test
try (final Tx tx = app.tx()) {
Div div = app.nodeQuery(Div.class).andName("WidgetTestPage-Div").getFirst();
assertEquals(2, div.treeGetChildCount());
Object obj = null;
for (DOMNode n : div.getAllChildNodes()) {
obj = n;
break;
}
assertTrue(Div.class.isAssignableFrom(obj.getClass()));
Div clonedNode = (Div) obj;
assertEquals(0, clonedNode.getChildNodes().getLength());
assertEquals(3, app.nodeQuery(Div.class).andName("TestComponent").getResult().size());
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception.");
}
}
use of org.structr.web.entity.html.Html 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.web.entity.html.Html in project structr by structr.
the class DeploymentTest method test10SharedComponent.
@Test
public void test10SharedComponent() {
// setup
try (final Tx tx = app.tx()) {
// create first page
final Page page1 = Page.createNewPage(securityContext, "test10_1");
final Html html1 = createElement(page1, page1, "html");
final Head head1 = createElement(page1, html1, "head");
createElement(page1, head1, "title", "test10_1");
final Body body1 = createElement(page1, html1, "body");
final Div div1 = createElement(page1, body1, "div");
createElement(page1, div1, "div", "test1");
createElement(page1, div1, "div", "test1");
final Div component = createComponent(div1);
// create second page
final Page page2 = Page.createNewPage(securityContext, "test10_2");
final Html html2 = createElement(page2, page2, "html");
final Head head2 = createElement(page2, html2, "head");
createElement(page2, head2, "title", "test10_2");
final Body body2 = createElement(page2, html2, "body");
final Div div2 = createElement(page2, body2, "div");
// re-use template from above
cloneComponent(component, div2);
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
// test
compare(calculateHash(), true);
}
Aggregations