Search in sources :

Example 11 with AbstractEqualsTest

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

the class TextComponentText method equals.

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

        @Override
        public Object getObjectX() {
            return TextComponent.create().text("text").build();
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { ImageComponent.create().image(ContentId.from("image")).build(), TextComponent.create().text("textComponent").build(), ImageComponent.create().build(), new Object() };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return TextComponent.create().text("text").build();
        }

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

Example 12 with AbstractEqualsTest

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

the class PropertyArrayTest method equals.

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

        @Override
        public Object getObjectX() {
            PropertyTree tree = new PropertyTree();
            final PropertyArray propertyArray = new PropertyArray(tree, tree.getRoot(), "myProp", ValueTypes.STRING);
            propertyArray.addValue(ValueFactory.newString("myValue"));
            return propertyArray;
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            PropertyTree tree = new PropertyTree();
            final PropertyArray propertyArray1 = new PropertyArray(tree, tree.getRoot(), "myProp", ValueTypes.STRING);
            propertyArray1.addValue(ValueFactory.newString("otherValue"));
            final PropertyArray propertyArray2 = new PropertyArray(tree, tree.getRoot(), "myProp", ValueTypes.XML);
            propertyArray2.addValue(ValueFactory.newXml("otherValue"));
            return new Object[] { propertyArray1, propertyArray2 };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            PropertyTree tree = new PropertyTree();
            final PropertyArray propertyArray = new PropertyArray(tree, tree.getRoot(), "myProp", ValueTypes.STRING);
            propertyArray.addValue(ValueFactory.newString("myValue"));
            return propertyArray;
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            PropertyTree tree = new PropertyTree();
            final PropertyArray propertyArray = new PropertyArray(tree, tree.getRoot(), "myProp", ValueTypes.STRING);
            propertyArray.addValue(ValueFactory.newString("myValue"));
            return propertyArray;
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 13 with AbstractEqualsTest

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

the class PropertyTest method equals.

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

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

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            PropertyTree tree = new PropertyTree();
            return new Object[] { tree.addString("myString", "otherValue"), tree.addString("otherString", "myValue"), tree.addXml("otherType", "myValue") };
        }

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

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

Example 14 with AbstractEqualsTest

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

the class ContentNameTest method equals.

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

        @Override
        public Object getObjectX() {
            return ContentName.from("mycontent");
        }

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

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return ContentName.from("mycontent");
        }

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

Example 15 with AbstractEqualsTest

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

the class ContentPathTest method equals.

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

        @Override
        public Object getObjectX() {
            return ContentPath.from("/myPath/myContent");
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { ContentPath.from("myPath/myContent"), ContentPath.from("myContent"), ContentPath.from("/myPath/myContent2") };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return ContentPath.from("/myPath/myContent");
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return ContentPath.from("/myPath/myContent");
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : 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