alessandrobenedetti commented on code in PR #3151:
URL: https://github.com/apache/solr/pull/3151#discussion_r1964100880


##########
solr/modules/llm/src/test/org/apache/solr/llm/textvectorisation/update/processor/TextToVectorUpdateProcessorFactoryTest.java:
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.llm.textvectorisation.update.processor;
+
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.params.MultiMapSolrParams;
+import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
+import org.apache.solr.llm.TestLlmBase;
+import org.apache.solr.request.SolrQueryRequestBase;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class TextToVectorUpdateProcessorFactoryTest extends TestLlmBase {
+  private TextToVectorUpdateProcessorFactory factoryToTest =
+      new TextToVectorUpdateProcessorFactory();
+  private NamedList<String> args = new NamedList<>();
+  
+  @BeforeClass
+  public static void initArgs() throws Exception {
+    setupTest("solrconfig-llm.xml", "schema.xml", false, false);
+  }
+
+  @AfterClass
+  public static void after() throws Exception {
+    afterTest();
+  }
+
+  @Test
+  public void init_fullArgs_shouldInitAllParams() {
+    args.add("inputField", "_text_");
+    args.add("outputField", "vector");
+    args.add("model", "model1");
+    factoryToTest.init(args);
+
+    assertEquals("_text_", factoryToTest.getInputField());
+    assertEquals("vector", factoryToTest.getOutputField());
+    assertEquals("model1", factoryToTest.getModelName());
+  }
+
+  @Test
+  public void init_nullInputField_shouldThrowExceptionWithDetailedMessage() {
+    args.add("outputField", "vector");
+    args.add("model", "model1");
+    
+    SolrException e = assertThrows(SolrException.class, () -> 
factoryToTest.init(args));
+    assertEquals("Missing required parameter: inputField", e.getMessage());
+  }
+
+  @Test
+  public void init_nullOutputField_shouldThrowExceptionWithDetailedMessage() {
+    args.add("inputField", "_text_");
+    args.add("model", "model1");
+    
+    SolrException e = assertThrows(SolrException.class, () -> 
factoryToTest.init(args));
+    assertEquals("Missing required parameter: outputField", e.getMessage());
+  }
+  
+  @Test
+  public void init_nullModel_shouldThrowExceptionWithDetailedMessage() {
+    args.add("inputField", "_text_");
+    args.add("outputField", "vector");
+    
+    SolrException e = assertThrows(SolrException.class, () -> 
factoryToTest.init(args));
+    assertEquals("Missing required parameter: model", e.getMessage());
+  }
+
+  /* Following tests depends on a real solr schema */
+  @Test
+  public void 
init_notExistentOutputField_shouldThrowExceptionWithDetailedMessage() throws 
Exception {
+    args.add("inputField", "_text_");
+    args.add("outputField", "notExistentOutput");
+    args.add("model", "model1");
+
+    Map<String, String[]> params = new HashMap<>();
+    MultiMapSolrParams mmparams = new MultiMapSolrParams(params);

Review Comment:
   Thanks! just pushed it!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to