Skip to content

Commit

Permalink
Refactoring test code (#302)
Browse files Browse the repository at this point in the history
Make buildGeoJSONFeatureProcessorConfig method to be more general

Signed-off-by: Heemin Kim <heemin@amazon.com>
  • Loading branch information
heemin32 committed May 11, 2023
1 parent e0c3b07 commit 5d79a58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.opensearch.geospatial.action.upload.geojson.UploadGeoJSONRequestContent;
import org.opensearch.geospatial.index.mapper.xyshape.XYShapeFieldMapper;
import org.opensearch.geospatial.index.query.xyshape.XYShapeQueryBuilder;
import org.opensearch.geospatial.processor.FeatureProcessor;
import org.opensearch.geospatial.rest.action.upload.geojson.RestUploadGeoJSONAction;
import org.opensearch.ingest.Pipeline;
import org.opensearch.rest.RestStatus;
Expand Down Expand Up @@ -75,7 +74,7 @@ private static String buildPipelinePath(String name) {
return String.join(URL_DELIMITER, "_ingest", "pipeline", name);
}

protected static void createPipeline(String name, Optional<String> description, List<Map<String, Object>> processorConfigs)
protected static Response createPipeline(String name, Optional<String> description, List<Map<String, Object>> processorConfigs)
throws IOException {
XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
if (description.isPresent()) {
Expand All @@ -88,7 +87,7 @@ protected static void createPipeline(String name, Optional<String> description,

Request request = new Request("PUT", buildPipelinePath(name));
request.setJsonEntity(Strings.toString(builder));
client().performRequest(request);
return client().performRequest(request);
}

protected static void deletePipeline(String name) throws IOException {
Expand Down Expand Up @@ -137,9 +136,9 @@ public static String indexDocument(String indexName, String docID, String body,
return docID;
}

protected Map<String, Object> buildGeoJSONFeatureProcessorConfig(Map<String, String> properties) {
protected Map<String, Object> buildProcessorConfig(final String processorType, final Map<String, String> properties) {
Map<String, Object> featureProcessor = new HashMap<>();
featureProcessor.put(FeatureProcessor.TYPE, properties);
featureProcessor.put(processorType, properties);
return featureProcessor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testIndexGeoJSONSuccess() throws Exception {

Map<String, String> processorProperties = new HashMap<>();
processorProperties.put(FeatureProcessor.FIELD_KEY, geoShapeField);
Map<String, Object> geoJSONProcessorConfig = buildGeoJSONFeatureProcessorConfig(processorProperties);
Map<String, Object> geoJSONProcessorConfig = buildProcessorConfig(FeatureProcessor.TYPE, processorProperties);
List<Map<String, Object>> configs = new ArrayList<>();
configs.add(geoJSONProcessorConfig);

Expand Down

0 comments on commit 5d79a58

Please sign in to comment.