Dbeaver/dbeaver#39228 fix model config uppercase modification (#39282)

* dbeaver/dbeaver#39228: add test bundle

* dbeaver/dbeaver#39228: fix return model name original case if unknown

* dbeaver/dbeaver#39228: fix codacy issues

* dbeaver/dbeaver#39191: fix codacy issues

---------

Co-authored-by: Matvey16 <82543000+Matvey16@users.noreply.github.com>
This commit is contained in:
Solovev Anton
2025-09-29 11:14:22 +02:00
committed by GitHub
parent 0eba22fbfa
commit 27f88a3a41
7 changed files with 115 additions and 1 deletions

View File

@@ -23,4 +23,5 @@
<plugin id="org.jkiss.dbeaver.ext.altibase.test" version="0.0.0"/>
<plugin id="org.jkiss.dbeaver.ext.clickhouse.test" version="0.0.0"/>
<plugin id="org.jkiss.dbeaver.ext.generic.test" version="0.0.0"/>
<plugin id="org.jkiss.dbeaver.model.ai.test" version="0.0.0"/>
</feature>

View File

@@ -87,7 +87,7 @@ public final class OpenAIModels {
if (DEPRECATED_MODELS.contains(lowerCaseModelName)) {
return DEFAULT_MODEL;
}
return lowerCaseModelName;
return modelName;
}
@NotNull

View File

@@ -0,0 +1,16 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: DBeaver AI Tests
Bundle-SymbolicName: org.jkiss.dbeaver.model.ai.test
Bundle-Version: 1.0.0.qualifier
Bundle-Release-Date: 20251006
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: DBeaver Corp
Fragment-Host: org.jkiss.dbeaver.model.ai
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.junit,
org.mockito.mockito-core,
org.jkiss.dbeaver.test.platform,
org.jkiss.dbeaver.model.ai

View File

@@ -0,0 +1,5 @@
source..=src/
output..=target/classes/
bin.includes=.,\
META-INF/
.

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ DBeaver - Universal Database Manager
~ Copyright (C) 2010-2024 DBeaver Corp and others
~
~ Licensed 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jkiss.dbeaver</groupId>
<artifactId>tests</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<artifactId>org.jkiss.dbeaver.model.ai.test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>

View File

@@ -0,0 +1,59 @@
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2025 DBeaver Corp and others
*
* Licensed 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.jkiss.dbeaver.model.ai.engine.openai;
import org.jkiss.junit.DBeaverUnitTest;
import org.junit.Test;
import static org.jkiss.dbeaver.model.ai.engine.openai.OpenAIModels.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeFalse;
public class OpenAIModelsTest extends DBeaverUnitTest {
@Test
public void effectiveModelNameNullShouldReturnDefaultModelName() {
//when
var result = getEffectiveModelName(null);
//then
assertEquals(DEFAULT_MODEL, result);
}
@Test
public void effectiveModelNameKnownUppercaseShouldReturnKnownModelLowercase() {
//given
var expectedModelName = KNOWN_MODELS.keySet().stream().findFirst().orElseThrow();
var inputModelName = expectedModelName.toUpperCase();
//when
var result = getEffectiveModelName(inputModelName);
//then
assertEquals(expectedModelName, result);
}
@Test
public void effectiveModelNameUnknownUppercaseShouldReturnKnownModelUppercase() {
//given
var inputModelName = "some-UNKNOWN-MODEL";
assumeFalse(KNOWN_MODELS.containsKey(inputModelName.toLowerCase()));
//when
var result = getEffectiveModelName(inputModelName);
//then
assertEquals(inputModelName, result);
}
}

View File

@@ -26,6 +26,7 @@
<module>org.jkiss.dbeaver.ext.snowflake.test</module>
<module>org.jkiss.dbeaver.ext.sqlite.test</module>
<module>org.jkiss.dbeaver.model.lsm.test</module>
<module>org.jkiss.dbeaver.model.ai.test</module>
</modules>
<build>