Skip to content

Commit

Permalink
CASL-611 Iterate w/o handle
Browse files Browse the repository at this point in the history
Signed-off-by: adamczyk-HERE <[email protected]>
  • Loading branch information
adamczyk-HERE committed Oct 21, 2024
1 parent cafe7b5 commit cdb38cb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
import com.here.naksha.lib.core.models.naksha.Space;
import com.here.naksha.lib.core.models.payload.Event;
import com.here.naksha.lib.core.models.payload.events.PropertyQueryOr;
import com.here.naksha.lib.core.models.payload.events.feature.GetFeaturesByBBoxEvent;
import com.here.naksha.lib.core.models.payload.events.feature.GetFeaturesByIdEvent;
import com.here.naksha.lib.core.models.payload.events.feature.GetFeaturesByTileEvent;
import com.here.naksha.lib.core.models.payload.events.feature.QueryEvent;
import com.here.naksha.lib.core.models.payload.events.feature.*;
import com.here.naksha.lib.core.models.storage.POp;
import com.here.naksha.lib.core.models.storage.ReadFeatures;
import com.here.naksha.lib.core.models.storage.ReadFeaturesProxyWrapper;
Expand All @@ -57,6 +54,7 @@ public static Result execute(NakshaContext context, ReadFeaturesProxyWrapper req
case GET_BY_IDS -> createFeaturesByIdsEvent(request);
case GET_BY_BBOX -> createFeatureByBBoxEvent(request);
case GET_BY_TILE -> createFeaturesByTileEvent(request);
case ITERATE -> createIterateEvent(request);
default -> throw new IllegalStateException("Unexpected value: " + request.getReadRequestType());
};

Expand All @@ -69,6 +67,10 @@ public static Result execute(NakshaContext context, ReadFeaturesProxyWrapper req
return PrepareResult.prepareResult(httpResponse, XyzFeatureCollection.class, XyzFeatureCollection::getFeatures);
}

private static Event createIterateEvent(ReadFeaturesProxyWrapper request) {
return new IterateFeaturesEvent();
}

private static Event createFeaturesByIdsEvent(ReadFeaturesProxyWrapper request) {
List<String> id = request.getQueryParameter(FEATURE_IDS);
return new GetFeaturesByIdEvent().withIds(id);
Expand Down Expand Up @@ -119,7 +121,7 @@ private static Event createFeaturesByTileEvent(ReadFeaturesProxyWrapper readRequ
boolean clip = readRequest.getQueryParameter(CLIP_GEO);

GetFeaturesByTileEvent event = new GetFeaturesByTileEvent();
event.setMargin((int) margin); // TODO-a
event.setMargin((int) margin);
event.setLimit(limit);
event.setClip(clip);
setPropertyOp(readRequest, event);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.here.naksha.storage.http.connector.integration;

import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.List;
import java.util.stream.IntStream;

import static com.here.naksha.storage.http.connector.integration.Commons.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class IterateTest {
@BeforeEach
void rmFeatures() {
rmAllFeatures();
}

@Test
void test() {
IntStream.rangeClosed(1,5).forEach( i ->
createFromJsonFileFormatted("iterate/feature_template.json",String.valueOf(i) )
);

String path = "iterate";
Response dhResponse = dataHub().get(path);
Response nResponse = naksha().get(path);
assertTrue(responseHasExactShortIds(List.of("1","2","3","4","5"), dhResponse));
assertTrue(responseHasExactShortIds(List.of("1","2","3","4","5"), nResponse));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "urn:here::here:landmark3d.Landmark3dPhotoreal:%s",
"type": "Feature",
"momType": "landmark3d.Landmark3dPhotoreal",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[[[-3, -3, 0], [0, -3, 0], [0, 0, 0], [-3, 0, 0], [-3, -3, 0]]]
]
}
}

0 comments on commit cdb38cb

Please sign in to comment.