Search in sources :

Example 1 with AbstractEqualsTest

use of com.enonic.xp.support.AbstractEqualsTest in project xp by enonic.

the class PropertyPathTest method equals.

@Test
public void equals() {
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return PropertyPath.from("a.b.c");
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { PropertyPath.from("a.b"), PropertyPath.from("a.b.c.d"), PropertyPath.from("a.b.b"), PropertyPath.from(".a.b.c") };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return PropertyPath.from("a.b.c");
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return PropertyPath.from("a.b.c");
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 2 with AbstractEqualsTest

use of com.enonic.xp.support.AbstractEqualsTest in project xp by enonic.

the class PropertyTreeTest method equals.

@Test
public void equals() {
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            PropertyTree tree = new PropertyTree();
            tree.addString("myString", "myValue");
            PropertySet set = tree.addSet("mySet");
            set.addString("myString", "myValue");
            return tree;
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            PropertyTree tree1 = new PropertyTree();
            tree1.addString("myString", "myValue");
            PropertySet set1 = tree1.addSet("mySet");
            set1.addString("myString", "otherValue");
            PropertyTree tree2 = new PropertyTree();
            tree2.addString("myString", "otherValue");
            PropertySet set2 = tree2.addSet("mySet");
            set2.addString("myString", "myValue");
            PropertyTree tree3 = new PropertyTree();
            tree3.addString("myString", "myValue");
            PropertySet set3 = tree3.addSet("myOtherSet");
            set3.addString("myString", "myValue");
            return new Object[] { tree1, tree2, tree3, new Object() };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            PropertyTree tree = new PropertyTree();
            tree.addString("myString", "myValue");
            PropertySet set = tree.addSet("mySet");
            set.addString("myString", "myValue");
            return tree;
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            PropertyTree tree = new PropertyTree();
            tree.addString("myString", "myValue");
            PropertySet set = tree.addSet("mySet");
            set.addString("myString", "myValue");
            return tree;
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 3 with AbstractEqualsTest

use of com.enonic.xp.support.AbstractEqualsTest in project xp by enonic.

the class NodePathTest method equals.

@Test
public void equals() {
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return new NodePath("/myPath/myItem");
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { new NodePath("/myPath") };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return new NodePath("/myPath/myItem");
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return new NodePath("/myPath/myItem");
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 4 with AbstractEqualsTest

use of com.enonic.xp.support.AbstractEqualsTest in project xp by enonic.

the class NodeNameTest method equals.

@Test
public void equals() {
    final AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return NodeName.from("name");
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { NodeName.from("other") };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return NodeName.from("name");
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return NodeName.from("name");
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 5 with AbstractEqualsTest

use of com.enonic.xp.support.AbstractEqualsTest in project xp by enonic.

the class NodeTest method equals.

@Test
public void equals() {
    NodeName name1 = NodeName.from("name1");
    NodeName name2 = NodeName.from("name2");
    ChildOrder childOrder1 = ChildOrder.defaultOrder();
    ChildOrder childOrder2 = ChildOrder.manualOrder();
    PropertyTree data1 = new PropertyTree();
    data1.addString("some", "config");
    PropertyTree data2 = new PropertyTree();
    data2.addString("other", "config");
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return Node.create().name(name1).data(data1).childOrder(childOrder1).build();
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            Node notX1 = Node.create().name(name2).data(data1).childOrder(childOrder1).build();
            Node notX2 = Node.create().name(name1).data(data2).childOrder(childOrder1).build();
            Node notX3 = Node.create().name(name1).data(data1).childOrder(childOrder2).build();
            return new Object[] { notX1, notX2, notX3 };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return Node.create().name(name1).data(data1).childOrder(childOrder1).build();
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return Node.create().name(name1).data(data1).childOrder(childOrder1).build();
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : ChildOrder(com.enonic.xp.index.ChildOrder) PropertyTree(com.enonic.xp.data.PropertyTree) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Aggregations

AbstractEqualsTest (com.enonic.xp.support.AbstractEqualsTest)23 Test (org.junit.jupiter.api.Test)23 PropertyTree (com.enonic.xp.data.PropertyTree)3 ChildOrder (com.enonic.xp.index.ChildOrder)1 Region (com.enonic.xp.region.Region)1