Search in sources :

Example 6 with TestFour

use of org.structr.core.entity.TestFour in project structr by structr.

the class PropertyTest method testLongProperty.

// ----- long property tests -----
@Test
public void testLongProperty() {
    try {
        final Property<Long> instance = TestFour.longProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store long in the test entitiy
        final Long value = 2857312362L;
        try (final Tx tx = app.tx()) {
            instance.setProperty(securityContext, testEntity, value);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, instance.getProperty(securityContext, testEntity, true));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 7 with TestFour

use of org.structr.core.entity.TestFour in project structr by structr.

the class PropertyTest method testPositiveInfinityDoublePropertySearchOnNode.

@Test
public void testPositiveInfinityDoublePropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Double> key = TestFour.doubleProperty;
        properties.put(key, Double.POSITIVE_INFINITY);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(Double.POSITIVE_INFINITY, testEntity.getProperty(key), 0.0);
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, Double.POSITIVE_INFINITY).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 8 with TestFour

use of org.structr.core.entity.TestFour in project structr by structr.

the class PropertyTest method testSimpleEnumProperty.

// ----- enum property tests -----
@Test
public void testSimpleEnumProperty() {
    try {
        final PropertyMap properties = new PropertyMap();
        properties.put(TestFour.enumProperty, TestEnum.Status1);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(TestEnum.Status1, testEntity.getProperty(TestFour.enumProperty));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 9 with TestFour

use of org.structr.core.entity.TestFour in project structr by structr.

the class PropertyTest method testDoubleProperty.

// ----- double property tests -----
@Test
public void testDoubleProperty() {
    try {
        final Property<Double> instance = TestFour.doubleProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store double in the test entitiy
        final Double value = 3.141592653589793238;
        try (final Tx tx = app.tx()) {
            instance.setProperty(securityContext, testEntity, value);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, instance.getProperty(securityContext, testEntity, true));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 10 with TestFour

use of org.structr.core.entity.TestFour in project structr by structr.

the class PropertyTest method testDateProperty.

// ----- date property tests -----
@Test
public void testDateProperty() {
    try {
        final Property<Date> instance = TestFour.dateProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store Date in the test entitiy
        final Date value = new Date(123456789L);
        try (final Tx tx = app.tx()) {
            instance.setProperty(securityContext, testEntity, value);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, instance.getProperty(securityContext, testEntity, true));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) Date(java.util.Date) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)37 StructrTest (org.structr.common.StructrTest)37 FrameworkException (org.structr.common.error.FrameworkException)37 TestFour (org.structr.core.entity.TestFour)37 Tx (org.structr.core.graph.Tx)37 TestOne (org.structr.core.entity.TestOne)8 OneFourOneToOne (org.structr.core.entity.OneFourOneToOne)6 Date (java.util.Date)5 UnlicensedException (org.structr.common.error.UnlicensedException)2 TestEnum (org.structr.core.entity.TestEnum)2 TestSix (org.structr.core.entity.TestSix)2 TestThree (org.structr.core.entity.TestThree)2 TestTwo (org.structr.core.entity.TestTwo)2 ActionContext (org.structr.schema.action.ActionContext)2 DecimalFormat (java.text.DecimalFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Collection (java.util.Collection)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1