use of org.structr.core.Result in project structr by structr.
the class SearchAndSortingTest method test10SearchByEmptyDateField.
@Test
public void test10SearchByEmptyDateField() {
try {
PropertyMap props = new PropertyMap();
AbstractNode node = createTestNode(TestOne.class, props);
try (final Tx tx = app.tx()) {
Result result = app.nodeQuery(TestOne.class).and(TestOne.aDate, null).includeDeletedAndHidden().getResult();
assertTrue(result.size() == 1);
assertTrue(result.get(0).equals(node));
}
} catch (FrameworkException ex) {
logger.warn("", ex);
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.Result in project structr by structr.
the class SearchAndSortingTest method test13SearchByEmptyDoubleField.
@Test
public void test13SearchByEmptyDoubleField() {
try {
PropertyMap props = new PropertyMap();
AbstractNode node = createTestNode(TestOne.class, props);
try (final Tx tx = app.tx()) {
Result result = app.nodeQuery(TestOne.class).and(TestOne.aDouble, null).includeDeletedAndHidden().getResult();
assertTrue(result.size() == 1);
assertTrue(result.get(0).equals(node));
tx.success();
}
} catch (FrameworkException ex) {
logger.warn("", ex);
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.Result in project structr by structr.
the class SearchAndSortingTest method test02SeachByNameProperty.
@Test
public void test02SeachByNameProperty() {
try {
Class type = TestOne.class;
int number = 4;
final List<NodeInterface> nodes = this.createTestNodes(type, number);
final int offset = 10;
Collections.shuffle(nodes, new Random(System.nanoTime()));
try (final Tx tx = app.tx()) {
int i = offset;
String name;
for (NodeInterface node : nodes) {
// System.out.println("Node ID: " + node.getNodeId());
name = "TestOne-" + i;
i++;
node.setProperty(AbstractNode.name, name);
}
tx.success();
}
try (final Tx tx = app.tx()) {
Result result = app.nodeQuery(type).and(TestOne.name, "TestOne-13").getResult();
assertEquals(1, result.size());
tx.success();
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.Result in project structr by structr.
the class SearchAndSortingTest method test04SeachByNamePropertyLooseUppercase.
@Test
public void test04SeachByNamePropertyLooseUppercase() {
try {
Class type = TestOne.class;
int number = 4;
final List<NodeInterface> nodes = this.createTestNodes(type, number);
final int offset = 10;
Collections.shuffle(nodes, new Random(System.nanoTime()));
try (final Tx tx = app.tx()) {
int i = offset;
String name;
for (NodeInterface node : nodes) {
// System.out.println("Node ID: " + node.getNodeId());
name = "TestOne-" + i;
i++;
node.setProperty(AbstractNode.name, name);
}
tx.success();
}
try (final Tx tx = app.tx()) {
Result result = app.nodeQuery(type).and(TestOne.name, "TestOne", false).getResult();
assertEquals(4, result.size());
tx.success();
}
} catch (FrameworkException ex) {
logger.error(ex.toString());
fail("Unexpected exception");
}
}
use of org.structr.core.Result in project structr by structr.
the class AccessControlTest method test01PublicAccessToNonPublicNode.
@Test
public void test01PublicAccessToNonPublicNode() {
final Class principalType = StructrApp.getConfiguration().getNodeEntityClass("Principal");
// remove auto-generated resource access objects
clearResourceAccess();
try {
Principal user = (Principal) createTestNode(principalType);
// Create node with user context
Class type = TestOne.class;
createTestNode(TestOne.class, user);
SecurityContext publicContext = SecurityContext.getInstance(null, AccessMode.Frontend);
try (final Tx tx = app.tx()) {
Result result = StructrApp.getInstance(publicContext).nodeQuery(type).getResult();
// Node should not be visible in public context (no user logged in)
assertTrue(result.isEmpty());
}
} catch (FrameworkException ex) {
logger.warn("", ex);
fail("Unexpected exception");
}
}
Aggregations