2525
2626import static org .junit .jupiter .api .Assertions .assertEquals ;
2727import static org .junit .jupiter .api .Assertions .assertNotNull ;
28+ import static org .junit .jupiter .api .Assertions .assertTrue ;
2829import static org .mockito .Mockito .*;
2930
3031public class ElasticSearchTest {
@@ -61,10 +62,22 @@ public void searchFeatureSummaryTest() throws IOException {
6162 featureCollectionProperties .put ("key" , "satellite_ghrsst_l4_gamssa_1day_multi_sensor_world.zarr" );
6263 esFeatureCollection .setProperties (featureCollectionProperties );
6364 var coords = new ArrayList <List <List <BigDecimal >>>();
65+ var esFeature = new EsFeatureModel ();
66+
67+ // mock a single point [147.338884, -43.190779]
68+ List <List <BigDecimal >> ring = new ArrayList <>();
69+ List <BigDecimal > point = List .of (
70+ new BigDecimal ("147.338884" ),
71+ new BigDecimal ("-43.190779" )
72+ );
73+ ring .add (point );
74+ coords .add (ring );
75+
6476 var polygon = new EsPolygonModel ();
6577 polygon .setCoordinates (coords );
66- var esFeature = new EsFeatureModel ();
78+
6779 esFeature .setGeometry (polygon );
80+
6881 esFeatureCollection .setFeatures (List .of (esFeature ));
6982
7083 when (hit .source ()).thenReturn (esFeatureCollection );
@@ -88,7 +101,18 @@ public void searchFeatureSummaryTest() throws IOException {
88101 assertNotNull (result );
89102 assertEquals (1 , result .getCollections ().size ());
90103 assertEquals (1L , result .getTotal ());
91- assertEquals (esFeature .toFeatureGeoJSON (), result .getCollections ().get (0 ));
104+ // validate geometry keeps same after adding key property
105+ assertEquals (esFeature .toFeatureGeoJSON ().getGeometry (),
106+ result .getCollections ().get (0 ).getGeometry ());
107+
108+ // validate key is in properties
109+ FeatureGeoJSON returnedFeature = result .getCollections ().get (0 );
110+ @ SuppressWarnings ("unchecked" )
111+ Map <String , Object > featureProps = (Map <String , Object >) returnedFeature .getProperties ();
112+
113+ assertTrue (featureProps .containsKey ("key" ));
114+ assertEquals ("satellite_ghrsst_l4_gamssa_1day_multi_sensor_world.zarr" ,
115+ featureProps .get ("key" ));
92116 }
93117
94118
0 commit comments