package org.geolatte.common.dataformats.json.to; import junit.framework.Assert; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.Warning; import org.junit.Test; /** * Unit test for {@link PolygonTo}. * * @author Bert Vanhooff [<a href="http://www.qmino.com">Qmino bvba</a>] */ public class PolygonToTest { @Test public void testEquals() throws Exception { // Checks a number of standard properties of the equals contract EqualsVerifier.forClass(PolygonTo.class).withRedefinedSuperclass().suppress(Warning.NONFINAL_FIELDS).verify(); CrsTo crsTo1 = ToTestHelper.createCrsTo("EPSG:900913"); CrsTo crsTo2 = ToTestHelper.createCrsTo("EPSG:4326"); PolygonTo first = null; PolygonTo second = null; // Equal objects first = new PolygonTo(crsTo1, new double[][][]{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); second = new PolygonTo(crsTo1, new double[][][]{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); Assert.assertTrue(first.equals(second)); Assert.assertTrue(second.equals(first)); // Different CRS first = new PolygonTo(crsTo1, new double[][][]{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); second = new PolygonTo(crsTo2, new double[][][]{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); EqualsVerifier.forExamples(first, second).withRedefinedSuperclass().suppress(Warning.NONFINAL_FIELDS).verify(); // Different Coordinates first = new PolygonTo(crsTo1, new double[][][]{{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); second = new PolygonTo(crsTo1, new double[][][]{{{9, 2}, {3, 4}}, {{5, 6}, {7, 8}}}); EqualsVerifier.forExamples(first, second).withRedefinedSuperclass().suppress(Warning.NONFINAL_FIELDS).verify(); } }