Skip to content

Commit

Permalink
fix unit tests for inference processor
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Mar 1, 2024
1 parent cd323ab commit 6065b6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class SparseEncodingProcessorTests extends OpenSearchTestCase {
@Mock
private Environment env;

@Mock
private ProcessorInputValidator processorInputValidator;

@InjectMocks
private SparseEncodingProcessorFactory SparseEncodingProcessorFactory;
private static final String PROCESSOR_TAG = "mockTag";
Expand Down Expand Up @@ -97,7 +100,11 @@ public void testExecute_whenInferenceTextListEmpty_SuccessWithoutAnyMap() {
IngestDocument ingestDocument = new IngestDocument(sourceAndMetadata, new HashMap<>());
Map<String, Processor.Factory> registry = new HashMap<>();
MLCommonsClientAccessor accessor = mock(MLCommonsClientAccessor.class);
SparseEncodingProcessorFactory sparseEncodingProcessorFactory = new SparseEncodingProcessorFactory(accessor, env);
SparseEncodingProcessorFactory sparseEncodingProcessorFactory = new SparseEncodingProcessorFactory(
accessor,
env,
processorInputValidator
);

Map<String, Object> config = new HashMap<>();
config.put(TextEmbeddingProcessor.MODEL_ID_FIELD, "mockModelId");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ public class TextEmbeddingProcessorTests extends OpenSearchTestCase {
@Mock
private Environment env;

@Mock
private ProcessorInputValidator processorInputValidator;

@InjectMocks
private TextEmbeddingProcessorFactory textEmbeddingProcessorFactory;
private static final String PROCESSOR_TAG = "mockTag";
Expand Down Expand Up @@ -127,7 +130,11 @@ public void testExecute_whenInferenceThrowInterruptedException_throwRuntimeExcep
IngestDocument ingestDocument = new IngestDocument(sourceAndMetadata, new HashMap<>());
Map<String, Processor.Factory> registry = new HashMap<>();
MLCommonsClientAccessor accessor = mock(MLCommonsClientAccessor.class);
TextEmbeddingProcessorFactory textEmbeddingProcessorFactory = new TextEmbeddingProcessorFactory(accessor, env);
TextEmbeddingProcessorFactory textEmbeddingProcessorFactory = new TextEmbeddingProcessorFactory(
accessor,
env,
processorInputValidator
);

Map<String, Object> config = new HashMap<>();
config.put(TextEmbeddingProcessor.MODEL_ID_FIELD, "mockModelId");
Expand All @@ -145,7 +152,11 @@ public void testExecute_whenInferenceTextListEmpty_SuccessWithoutEmbedding() {
IngestDocument ingestDocument = new IngestDocument(sourceAndMetadata, new HashMap<>());
Map<String, Processor.Factory> registry = new HashMap<>();
MLCommonsClientAccessor accessor = mock(MLCommonsClientAccessor.class);
TextEmbeddingProcessorFactory textEmbeddingProcessorFactory = new TextEmbeddingProcessorFactory(accessor, env);
TextEmbeddingProcessorFactory textEmbeddingProcessorFactory = new TextEmbeddingProcessorFactory(
accessor,
env,
processorInputValidator
);

Map<String, Object> config = new HashMap<>();
config.put(TextEmbeddingProcessor.MODEL_ID_FIELD, "mockModelId");
Expand Down

0 comments on commit 6065b6f

Please sign in to comment.