From c01c2266b839a8791c8a9cc62e3670655bb83a90 Mon Sep 17 00:00:00 2001 From: Yasin Date: Sun, 3 Dec 2017 16:51:42 +0530 Subject: [PATCH] BAEL-1334: Guide to Hibernate Spatial (#3183) * BAEL-1334 Guide to Hibernate Spatial * BAEL-1334 Guide to Hibernate Spatial Moving the files to hibernate5 from libraries * Reverting the pom file * BAEL-1334 Guide to Hibernate Spatial * BAEL-1334 Guide to Hibernate Spatial Moving the files to hibernate5 from libraries * Reverting the pom file * BAEL-1334 Guide to Hibernate Spatial Improved assertions --- .../java/com/baeldung/hibernate/HibernateSpatialTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hibernate5/src/test/java/com/baeldung/hibernate/HibernateSpatialTest.java b/hibernate5/src/test/java/com/baeldung/hibernate/HibernateSpatialTest.java index 6d0aa0a4cd..a5c7b329fc 100644 --- a/hibernate5/src/test/java/com/baeldung/hibernate/HibernateSpatialTest.java +++ b/hibernate5/src/test/java/com/baeldung/hibernate/HibernateSpatialTest.java @@ -14,7 +14,9 @@ import org.junit.Test; import javax.persistence.Query; import java.io.IOException; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; + import static org.junit.Assert.assertTrue; public class HibernateSpatialTest { @@ -76,10 +78,8 @@ public class HibernateSpatialTest { Query query = session.createQuery("select p from PointEntity p where within(p.point, :area) = true", PointEntity.class); query.setParameter("area", wktToGeometry("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))")); - assertEquals(3, query.getResultList().size()); - assertEquals("POINT (1 1)", ((PointEntity) query.getResultList().get(0)).getPoint().toString()); - assertEquals("POINT (1 2)", ((PointEntity) query.getResultList().get(1)).getPoint().toString()); - assertEquals("POINT (3 4)", ((PointEntity) query.getResultList().get(2)).getPoint().toString()); + assertThat(query.getResultList().stream().map(p -> ((PointEntity) p).getPoint().toString())) + .containsOnly("POINT (1 1)", "POINT (1 2)", "POINT (3 4)"); } private void insertPoint(String point) throws ParseException {