udpate global setting tests (#20925)

This commit is contained in:
William Cheng 2025-03-19 15:29:39 +08:00 committed by GitHub
parent 69e4336f67
commit 8a8bacd0d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,35 +2,37 @@ package org.openapitools.codegen.config;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import java.util.Properties;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import org.slf4j.LoggerFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Test class for {@link GlobalSettings}
*
* @author Edoardo Patti
*/
public class GlobalSettingsTest {
private static final Object OBJECT = new Object();
@BeforeClass
public void setUp() {
((Logger) LoggerFactory.getLogger(GlobalSettings.class)).setLevel(Level.DEBUG);
Properties props = new Properties(2);
props.put("test1", 789);
props.put(345, "test2");
System.getProperties().putAll(props);
}
@BeforeClass
public void setUp() {
((Logger) LoggerFactory.getLogger(GlobalSettings.class)).setLevel(Level.DEBUG);
Properties props = new Properties(2);
props.put("test1", OBJECT);
props.put(OBJECT, "test2");
System.getProperties().putAll(props);
}
@Test
public void testNonStringSystemProperties() {
assertThat(GlobalSettings.getProperty(OBJECT.toString())).isNotNull();
assertThat(GlobalSettings.getProperty("test1")).isNotNull();
assertThatNoException().isThrownBy(GlobalSettings::log);
}
@Test
public void testNonStringSystemProperties() {
assertThat(GlobalSettings.getProperty("345")).isEqualTo("test2");
assertThat(GlobalSettings.getProperty("test1")).isEqualTo("789");
assertThatNoException().isThrownBy(GlobalSettings::log);
}
}