Skip to content

Commit

Permalink
add ITs
Browse files Browse the repository at this point in the history
Signed-off-by: Mingshi Liu <[email protected]>
  • Loading branch information
mingshl committed Jul 22, 2024
1 parent bf4eda2 commit f8edd8c
Show file tree
Hide file tree
Showing 7 changed files with 1,603 additions and 177 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.HashMap;
import java.util.Map;

public class VersionedMapUtils {
public class MapUtils {

/**
* Increments the counter for the given key in the specified version.
Expand All @@ -35,4 +35,19 @@ public static int getCounter(Map<Integer, Map<String, Integer>> versionedCounter
return counters != null ? counters.getOrDefault(key, -1) : 0;
}

/**
* Increments the counter value for the given key in the provided counters map.
* If the key does not exist in the map, it is added with an initial counter value of 0.
*
* @param counters A map that stores integer counters for each integer key.
* @param key The integer key for which the counter needs to be incremented.
*/
public static void incrementCounter(Map<Integer, Integer> counters, int key) {
counters.put(key, counters.getOrDefault(key, 0) + 1);
}

public static int getCounter(Map<Integer, Integer> counters, int key) {
return counters.getOrDefault(key, 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.opensearch.ml.common.spi.MLCommonsExtension;
import org.opensearch.ml.common.spi.tools.Tool;
import org.opensearch.ml.engine.tools.MLModelTool;
import org.opensearch.ml.processor.MLInferenceSearchResponseProcessor;
import org.opensearch.plugins.ExtensiblePlugin;
import org.opensearch.plugins.SearchPipelinePlugin;
import org.opensearch.plugins.SearchPlugin;
Expand Down Expand Up @@ -83,10 +84,11 @@ public void testGetRequestProcessors() {
public void testGetResponseProcessors() {
SearchPipelinePlugin.Parameters parameters = mock(SearchPipelinePlugin.Parameters.class);
Map<String, ?> responseProcessors = plugin.getResponseProcessors(parameters);
assertEquals(1, responseProcessors.size());
assertEquals(2, responseProcessors.size());
assertTrue(
responseProcessors.get(GenerativeQAProcessorConstants.RESPONSE_PROCESSOR_TYPE) instanceof GenerativeQAResponseProcessor.Factory
);
assertTrue(responseProcessors.get(MLInferenceSearchResponseProcessor.TYPE) instanceof MLInferenceSearchResponseProcessor.Factory);
}

@Test
Expand Down
Loading

0 comments on commit f8edd8c

Please sign in to comment.