use of org.structr.web.entity.html.Table 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.Table 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.Table in project structr by structr.
the class DeploymentTest method test30IncreasingIndentationCountInRoundtrip.
@Test
public void test30IncreasingIndentationCountInRoundtrip() {
// setup
try (final Tx tx = app.tx()) {
final Page page = Page.createNewPage(securityContext, "test30");
final Html html = createElement(page, page, "html");
final Head head = createElement(page, html, "head");
createElement(page, head, "title", "test30");
final Body body = createElement(page, html, "body");
final Div div1 = createElement(page, body, "div");
final Div div2 = createElement(page, div1, "div", "This is a test.");
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", "content11", "Content before <select>");
final Td td12 = createElement(page, tr1, "td", "content12");
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", "value1");
final Option option2 = createElement(page, select, "option", "value2");
tx.success();
} catch (FrameworkException fex) {
fail("Unexpected exception.");
}
compare(calculateHash(), true);
}
use of org.structr.web.entity.html.Table in project structr by structr.
the class UiScriptingTest method testIncludeWithRepeaterInJavaScript.
@Test
public void testIncludeWithRepeaterInJavaScript() {
try (final Tx tx = app.tx()) {
final Page page = Page.createSimplePage(securityContext, "test");
final Div div = (Div) page.getElementsByTagName("div").item(0);
final Content content = (Content) div.getFirstChild();
// setup scripting repeater
content.setProperty(StructrApp.key(Content.class, "content"), "${{ var arr = []; for (var i=0; i<10; i++) { arr.push({name: 'test' + i}); } Structr.include('item', arr, 'test'); }}");
content.setProperty(StructrApp.key(Content.class, "contentType"), "text/html");
// setup shared component with name "table" to include
final ShadowDocument shadowDoc = CreateComponentCommand.getOrCreateHiddenDocument();
final Div item = (Div) shadowDoc.createElement("div");
final Content txt = (Content) shadowDoc.createTextNode("${test.name}");
item.setProperty(StructrApp.key(Table.class, "name"), "item");
item.appendChild(txt);
// create admin user
createTestNode(User.class, new NodeAttribute<>(StructrApp.key(User.class, "name"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "password"), "admin"), new NodeAttribute<>(StructrApp.key(User.class, "isAdmin"), true));
tx.success();
} catch (FrameworkException fex) {
fex.printStackTrace();
fail("Unexpected exception.");
}
RestAssured.basePath = "/";
// test successful basic auth
RestAssured.given().headers("X-User", "admin", "X-Password", "admin").filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(200)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(400)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(401)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(403)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(404)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(422)).filter(ResponseLoggingFilter.logResponseIfStatusCodeIs(500)).expect().statusCode(200).body("html.head.title", Matchers.equalTo("Test")).body("html.body.h1", Matchers.equalTo("Test")).body("html.body.div.div[0]", Matchers.equalTo("test0")).body("html.body.div.div[1]", Matchers.equalTo("test1")).body("html.body.div.div[2]", Matchers.equalTo("test2")).body("html.body.div.div[3]", Matchers.equalTo("test3")).body("html.body.div.div[4]", Matchers.equalTo("test4")).body("html.body.div.div[5]", Matchers.equalTo("test5")).body("html.body.div.div[6]", Matchers.equalTo("test6")).body("html.body.div.div[7]", Matchers.equalTo("test7")).body("html.body.div.div[8]", Matchers.equalTo("test8")).body("html.body.div.div[9]", Matchers.equalTo("test9")).when().get("/html/test");
}
Aggregations