mirror of
https://github.com/dbeaver/dbeaver.git
synced 2025-11-05 13:17:47 +08:00
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:
@@ -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>
|
||||
|
||||
@@ -87,7 +87,7 @@ public final class OpenAIModels {
|
||||
if (DEPRECATED_MODELS.contains(lowerCaseModelName)) {
|
||||
return DEFAULT_MODEL;
|
||||
}
|
||||
return lowerCaseModelName;
|
||||
return modelName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
16
test/org.jkiss.dbeaver.model.ai.test/META-INF/MANIFEST.MF
Normal file
16
test/org.jkiss.dbeaver.model.ai.test/META-INF/MANIFEST.MF
Normal 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
|
||||
5
test/org.jkiss.dbeaver.model.ai.test/build.properties
Normal file
5
test/org.jkiss.dbeaver.model.ai.test/build.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
source..=src/
|
||||
output..=target/classes/
|
||||
bin.includes=.,\
|
||||
META-INF/
|
||||
.
|
||||
32
test/org.jkiss.dbeaver.model.ai.test/pom.xml
Normal file
32
test/org.jkiss.dbeaver.model.ai.test/pom.xml
Normal 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>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user