alessandrobenedetti commented on code in PR #3151: URL: https://github.com/apache/solr/pull/3151#discussion_r1943633074
########## solr/modules/llm/src/test/org/apache/solr/llm/texttovector/update/processor/TextToVectorUpdateProcessorFactoryTest.java: ########## @@ -0,0 +1,129 @@ +/* + * 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.texttovector.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_shouldInitFullClassificationParams() { + 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("Text to Vector UpdateProcessor 'inputField' can not be null", e.getMessage()); + } + + @Test + public void init_notExistentInputField_shouldThrowExceptionWithDetailedMessage() throws Exception { + args.add("inputField", "notExistentInput"); + args.add("outputField", "vector"); + args.add("model", "model1"); + + Map<String, String[]> params = new HashMap<>(); + MultiMapSolrParams mmparams = new MultiMapSolrParams(params); + SolrQueryRequestBase req = new SolrQueryRequestBase(solrClientTestRule.getCoreContainer().getCore("collection1"), (SolrParams) mmparams) {}; Review Comment: I admit I don't know, I'm not that java savvy, I suspect it has to do with instatiating a subclass of an abstract class? -- 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