use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testCaseInsensitiveMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode.
@Test
public void testCaseInsensitiveMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<String> key = TestFour.stringProperty;
properties.put(key, "xyz\r\nTeSt\r\nabc");
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals("xyz\r\nTeSt\r\nabc", testEntity.getProperty(key));
// inexact searc
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test", false).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Error in test");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode.
@Test
public void testMultilineWithLinefeedStringPropertyInexactSubstringSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<String> key = TestFour.stringProperty;
properties.put(key, "xyz\r\ntest\r\nabc");
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals("xyz\r\ntest\r\nabc", testEntity.getProperty(key));
// inexact searc
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test", false).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Error in test");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testModifyType.
// ----- type property tests -----
@Test
public void testModifyType() {
final DatabaseService db = StructrApp.getInstance().getDatabaseService();
final Set<Label> labelsBefore = new LinkedHashSet<>();
final Set<Label> labelsAfter = new LinkedHashSet<>();
String id = null;
labelsBefore.add(db.forName(Label.class, AccessControllable.class.getSimpleName()));
labelsBefore.add(db.forName(Label.class, TestFour.class.getSimpleName()));
labelsAfter.add(db.forName(Label.class, AccessControllable.class.getSimpleName()));
labelsAfter.add(db.forName(Label.class, TestFive.class.getSimpleName()));
try (final Tx tx = app.tx()) {
// create entity of type TestFour
final TestFour testEntity = createTestNode(TestFour.class);
// check if node exists
assertNotNull(testEntity);
// check labels before type change
assertTrue(Iterables.toSet(testEntity.getNode().getLabels()).containsAll(labelsBefore));
// save ID for later use
id = testEntity.getUuid();
// change type to TestFive
// system properties have to be unlocked now, admin rights are not enough anymore
testEntity.unlockSystemPropertiesOnce();
testEntity.setProperty(GraphObject.type, TestFive.class.getSimpleName());
// commit transaction
tx.success();
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception");
}
try (final Tx tx = app.tx()) {
final TestFive testEntity = app.get(TestFive.class, id);
assertNotNull(testEntity);
// check labels after type change
assertTrue(Iterables.toSet(testEntity.getNode().getLabels()).containsAll(labelsAfter));
} catch (FrameworkException fex) {
logger.warn("", fex);
fail("Unexpected exception");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testMultilineStringPropertyInexactSubstringSearchOnNode.
@Test
public void testMultilineStringPropertyInexactSubstringSearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<String> key = TestFour.stringProperty;
properties.put(key, "xyz\ntest\nabc");
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals("xyz\ntest\nabc", testEntity.getProperty(key));
// inexact searc
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, "test", false).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Error in test");
}
}
use of org.structr.core.entity.TestFour in project structr by structr.
the class PropertyTest method testSimpleBooleanPropertySearchOnNode.
@Test
public void testSimpleBooleanPropertySearchOnNode() {
try {
final PropertyMap properties = new PropertyMap();
final PropertyKey<Boolean> key = TestFour.booleanProperty;
properties.put(key, true);
final TestFour testEntity = createTestNode(TestFour.class, properties);
assertNotNull(testEntity);
try (final Tx tx = app.tx()) {
// check value from database
assertEquals((Boolean) true, (Boolean) testEntity.getProperty(key));
Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, true).getResult();
assertEquals(1, result.size());
assertEquals(testEntity, result.get(0));
}
} catch (FrameworkException fex) {
fail("Unable to store array");
}
}
Aggregations