From 0c0868e895c2ad0c1b82c1f57992e68378d1f3b0 Mon Sep 17 00:00:00 2001 From: Lester Solbakken Date: Fri, 3 May 2024 13:04:05 +0200 Subject: Use class.getName() instead of string --- .../RestartOnDeployForLocalLLMValidator.java | 2 +- .../RestartOnDeployForLocalLLMValidatorTest.java | 25 ++++++++++++++-------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'config-model') diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidator.java index c9b67ca4240..ccfc611c3dc 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidator.java @@ -21,7 +21,7 @@ import static java.util.stream.Collectors.toUnmodifiableSet; */ public class RestartOnDeployForLocalLLMValidator implements ChangeValidator { - private static final String LOCAL_LLM_COMPONENT = "ai.vespa.llm.clients.LocalLLM"; + public static final String LOCAL_LLM_COMPONENT = ai.vespa.llm.clients.LocalLLM.class.getName(); private static final Logger log = Logger.getLogger(RestartOnDeployForLocalLLMValidator.class.getName()); diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidatorTest.java index 311d4f39fcd..13e91f60712 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartOnDeployForLocalLLMValidatorTest.java @@ -19,21 +19,20 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class RestartOnDeployForLocalLLMValidatorTest { - public static final String OPENAI_LLM_COMPONENT = "ai.vespa.llm.clients.OpenAI"; - public static final String LOCAL_LLM_COMPONENT = "ai.vespa.llm.clients.LocalLLM"; + private static final String LOCAL_LLM_COMPONENT = RestartOnDeployForLocalLLMValidator.LOCAL_LLM_COMPONENT; @Test void validate_no_restart_on_deploy() { - VespaModel current = createModelWithComponent(OPENAI_LLM_COMPONENT); - VespaModel next = createModelWithComponent(LOCAL_LLM_COMPONENT); + VespaModel current = createModel(); + VespaModel next = createModel(withComponent(LOCAL_LLM_COMPONENT)); List result = validateModel(current, next); assertEquals(0, result.size()); } @Test void validate_restart_on_deploy() { - VespaModel current = createModelWithComponent(LOCAL_LLM_COMPONENT); - VespaModel next = createModelWithComponent(LOCAL_LLM_COMPONENT); + VespaModel current = createModel(withComponent(LOCAL_LLM_COMPONENT)); + VespaModel next = createModel(withComponent(LOCAL_LLM_COMPONENT)); List result = validateModel(current, next); assertEquals(1, result.size()); assertTrue(result.get(0).validationId().isEmpty()); @@ -46,21 +45,29 @@ public class RestartOnDeployForLocalLLMValidatorTest { deployStateBuilder().previousModel(current).build()); } - private static VespaModel createModelWithComponent(String componentClass) { + private static VespaModel createModel(String component) { var xml = """ - + %s - """.formatted(componentClass); + """.formatted(component); DeployState.Builder builder = deployStateBuilder(); return new VespaModelCreatorWithMockPkg(null, xml).create(builder); } + private static VespaModel createModel() { + return createModel(""); + } + + private static String withComponent(String componentClass) { + return "".formatted(componentClass); + } + private static DeployState.Builder deployStateBuilder() { return new DeployState.Builder().properties(new TestProperties()); } -- cgit v1.2.3