From 5d79a585fe4ea8b3e609d34c5602e3cda26294e5 Mon Sep 17 00:00:00 2001 From: Heemin Kim Date: Thu, 11 May 2023 14:13:22 -0700 Subject: [PATCH] Refactoring test code (#302) Make buildGeoJSONFeatureProcessorConfig method to be more general Signed-off-by: Heemin Kim --- .../opensearch/geospatial/GeospatialRestTestCase.java | 9 ++++----- .../geospatial/processor/FeatureProcessorIT.java | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/opensearch/geospatial/GeospatialRestTestCase.java b/src/test/java/org/opensearch/geospatial/GeospatialRestTestCase.java index 4ca9cfec..89685c9f 100644 --- a/src/test/java/org/opensearch/geospatial/GeospatialRestTestCase.java +++ b/src/test/java/org/opensearch/geospatial/GeospatialRestTestCase.java @@ -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; @@ -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 description, List> processorConfigs) + protected static Response createPipeline(String name, Optional description, List> processorConfigs) throws IOException { XContentBuilder builder = XContentFactory.jsonBuilder().startObject(); if (description.isPresent()) { @@ -88,7 +87,7 @@ protected static void createPipeline(String name, Optional 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 { @@ -137,9 +136,9 @@ public static String indexDocument(String indexName, String docID, String body, return docID; } - protected Map buildGeoJSONFeatureProcessorConfig(Map properties) { + protected Map buildProcessorConfig(final String processorType, final Map properties) { Map featureProcessor = new HashMap<>(); - featureProcessor.put(FeatureProcessor.TYPE, properties); + featureProcessor.put(processorType, properties); return featureProcessor; } diff --git a/src/test/java/org/opensearch/geospatial/processor/FeatureProcessorIT.java b/src/test/java/org/opensearch/geospatial/processor/FeatureProcessorIT.java index 8e256aae..f2677cf3 100644 --- a/src/test/java/org/opensearch/geospatial/processor/FeatureProcessorIT.java +++ b/src/test/java/org/opensearch/geospatial/processor/FeatureProcessorIT.java @@ -49,7 +49,7 @@ public void testIndexGeoJSONSuccess() throws Exception { Map processorProperties = new HashMap<>(); processorProperties.put(FeatureProcessor.FIELD_KEY, geoShapeField); - Map geoJSONProcessorConfig = buildGeoJSONFeatureProcessorConfig(processorProperties); + Map geoJSONProcessorConfig = buildProcessorConfig(FeatureProcessor.TYPE, processorProperties); List> configs = new ArrayList<>(); configs.add(geoJSONProcessorConfig);