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 23, 2024
1 parent bf4eda2 commit 7438c2d
Show file tree
Hide file tree
Showing 11 changed files with 1,789 additions and 184 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,16 @@ default String convertToDotPath(String path) {
* @param list the list to be checked
* @return true if the list contains all null elements or is empty, false otherwise
*/
default boolean isEmptyOrNullList(List list) {
static boolean isEmptyOrNullList(List list) {
if (list == null || list.isEmpty()) {
return true; // An empty list is considered to contain all null elements
return true;
}

for (Object obj : list) {
if (obj != null) {
return false; // If any element is not null, return false
return false;
}
}
return true; // If all elements are null, return true
return true;
}
}
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 @@ -14,9 +14,7 @@
import org.opensearch.search.profile.SearchProfileShardResults;

public class SearchResponseUtil {
private SearchResponseUtil() {

}
private SearchResponseUtil() {}

/**
* Construct a new {@link SearchResponse} based on an existing one, replacing just the {@link SearchHits}.
Expand Down
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 7438c2d

Please sign in to comment.