Search in sources :

Example 21 with TestFour

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

the class PropertyTest method testSimpleEnumPropertySearchOnRelationship.

@Test
public void testSimpleEnumPropertySearchOnRelationship() {
    try {
        final TestOne testOne = createTestNode(TestOne.class);
        final TestFour testFour = createTestNode(TestFour.class);
        final Property<TestEnum> key = OneFourOneToOne.enumProperty;
        assertNotNull(testOne);
        assertNotNull(testFour);
        final OneFourOneToOne testEntity = createTestRelationship(testOne, testFour, OneFourOneToOne.class);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, TestEnum.Status1);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(TestEnum.Status1, testEntity.getProperty(key));
            Result<OneFourOneToOne> result = app.relationshipQuery(OneFourOneToOne.class).and(key, TestEnum.Status1).getResult();
            assertEquals(1, result.size());
            assertEquals(testEntity, result.get(0));
        }
    } catch (FrameworkException fex) {
        fail("Unable to store array");
    }
}
Also used : OneFourOneToOne(org.structr.core.entity.OneFourOneToOne) TestFour(org.structr.core.entity.TestFour) Tx(org.structr.core.graph.Tx) FrameworkException(org.structr.common.error.FrameworkException) TestEnum(org.structr.core.entity.TestEnum) TestOne(org.structr.core.entity.TestOne) StructrTest(org.structr.common.StructrTest) Test(org.junit.Test)

Example 22 with TestFour

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

the class PropertyTest method testNegativeInfinityDoublePropertySearchOnNode.

/* temporarily disabled because Cypher cannot handle NaN yet..
	public void testNaNSearchOnNode() {

		try {

			final PropertyMap properties  = new PropertyMap();
			final PropertyKey<Double> key = TestFour.doubleProperty;

			properties.put(key, Double.NaN);

			final TestFour testEntity     = createTestNode(TestFour.class, properties);

			assertNotNull(testEntity);

			try (final Tx tx = app.tx()) {

				// check value from database
				assertEquals(Double.NaN, testEntity.getProperty(key));

				Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, Double.NaN).getResult();

				assertEquals(1, result.size());
				assertEquals(testEntity, result.get(0));
			}

		} catch (FrameworkException fex) {

			fail("Unable to store array");
		}

	}
	*/
@Test
public void testNegativeInfinityDoublePropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Double> key = TestFour.doubleProperty;
        properties.put(key, Double.NEGATIVE_INFINITY);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(Double.NEGATIVE_INFINITY, testEntity.getProperty(key), 0.0);
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, Double.NEGATIVE_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 23 with TestFour

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

the class PropertyTest method testIntProperty.

// ----- integer property tests -----
@Test
public void testIntProperty() {
    try {
        final Property<Integer> instance = TestFour.integerProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store integer in the test entitiy
        final Integer value = 2345;
        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 24 with TestFour

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

the class PropertyTest method testBooleanProperty.

// ----- boolean property tests -----
@Test
public void testBooleanProperty() {
    try {
        final Property<Boolean> key = TestFour.booleanProperty;
        final TestFour testEntity = createTestNode(TestFour.class);
        assertNotNull(testEntity);
        // store boolean in the test entitiy
        final Boolean value = Boolean.TRUE;
        try (final Tx tx = app.tx()) {
            testEntity.setProperty(key, value);
            tx.success();
        }
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(value, testEntity.getProperty(key));
        }
    } 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 25 with TestFour

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

the class PropertyTest method testSimpleDoublePropertySearchOnNode.

/* temporarily disabled because Cypher cannot handle NaN yet..
	public void testNaN() {

		try {

			final Property<Double> instance = TestFour.doubleProperty;
			final TestFour testEntity        = createTestNode(TestFour.class);

			assertNotNull(testEntity);

			// store NaN double in the test entitiy
			final Double value = Double.NaN;


			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");
		}
	}
	*/
@Test
public void testSimpleDoublePropertySearchOnNode() {
    try {
        final PropertyMap properties = new PropertyMap();
        final PropertyKey<Double> key = TestFour.doubleProperty;
        properties.put(key, 3.141592653589793238);
        final TestFour testEntity = createTestNode(TestFour.class, properties);
        assertNotNull(testEntity);
        try (final Tx tx = app.tx()) {
            // check value from database
            assertEquals(3.141592653589793238, testEntity.getProperty(key), 0.0);
            Result<TestFour> result = app.nodeQuery(TestFour.class).and(key, 3.141592653589793238).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)

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