Search in sources :

Example 6 with AbstractEqualsTest

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

the class PageTest method equals.

@Test
public void equals() {
    final PropertyTree config1 = new PropertyTree();
    config1.addString("some", "config");
    final PropertyTree config2 = new PropertyTree();
    config2.addString("other", "config");
    final Region region1 = Region.create().name("main").add(PartComponent.create().descriptor("descriptor-x").config(new PropertyTree()).build()).add(PartComponent.create().descriptor("descriptor-y").config(new PropertyTree()).build()).build();
    final Region region2 = Region.create().name("apart").add(PartComponent.create().descriptor("descriptor-x").config(new PropertyTree()).build()).add(PartComponent.create().descriptor("descriptor-y").config(new PropertyTree()).build()).build();
    AbstractEqualsTest equalsTest = new AbstractEqualsTest() {

        @Override
        public Object getObjectX() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            Page notX1 = Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region2).build()).build();
            Page notX2 = Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).add(region2).build()).build();
            Page notX3 = Page.create().config(config2).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
            Page notX4 = Page.create().config(config1).template(PageTemplateKey.from("template-y")).regions(PageRegions.create().add(region1).build()).build();
            return new Object[] { notX1, notX2, notX3, notX4, new Object() };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return Page.create().config(config1).template(PageTemplateKey.from("template-x")).regions(PageRegions.create().add(region1).build()).build();
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Region(com.enonic.xp.region.Region) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 7 with AbstractEqualsTest

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

the class ImageComponentTest method equals.

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

        @Override
        public Object getObjectX() {
            final PropertyTree config1 = new PropertyTree();
            config1.addString("some", "config");
            return ImageComponent.create().image(ContentId.from("image")).config(config1).build();
        }

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

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            final PropertyTree config1 = new PropertyTree();
            config1.addString("some", "config");
            return ImageComponent.create().image(ContentId.from("image")).config(config1).build();
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            final PropertyTree config1 = new PropertyTree();
            config1.addString("some", "config");
            return ImageComponent.create().image(ContentId.from("image")).config(config1).build();
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 8 with AbstractEqualsTest

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

the class LayoutComponentTest method equals.

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

        @Override
        public Object getObjectX() {
            return createLayouComponent();
        }

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

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return createLayouComponent();
        }

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

Example 9 with AbstractEqualsTest

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

the class RegionPathTest method equals.

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

        @Override
        public Object getObjectX() {
            return RegionPath.from("a-region/0/1");
        }

        @Override
        public Object[] getObjectsThatNotEqualsX() {
            return new Object[] { RegionPath.from("a-region/1/0"), RegionPath.from("a-region/0/0"), RegionPath.from("a-region"), new Object() };
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame() {
            return RegionPath.from("a-region/0/1");
        }

        @Override
        public Object getObjectThatEqualsXButNotTheSame2() {
            return RegionPath.from(ComponentPath.from("a-region/0"), "1");
        }
    };
    equalsTest.assertEqualsAndHashCodeContract();
}
Also used : AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest) Test(org.junit.jupiter.api.Test) AbstractEqualsTest(com.enonic.xp.support.AbstractEqualsTest)

Example 10 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)

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