Skip to content

Commit eb1f1ed

Browse files
committed
Reformat code
1 parent ddd5a19 commit eb1f1ed

File tree

1 file changed

+101
-101
lines changed

1 file changed

+101
-101
lines changed

clickhouse-client/src/test/java/com/clickhouse/client/config/ClickHouseConfigOptionTest.java

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -8,110 +8,110 @@
88
import com.clickhouse.client.ClickHouseFormat;
99

1010
public class ClickHouseConfigOptionTest {
11-
static enum ClickHouseTestOption implements ClickHouseOption {
12-
STR("string_option", "string", "string option"),
13-
STR0("string_option0", "string0", "string option without environment variable support"),
14-
STR1("string_option0", "string1",
15-
"string option without environment variable and system property support"),
16-
INT("integer_option", 2333, "integer option"),
17-
INT0("integer_option0", 23330, "integer option without environment variable support"),
18-
INT1("integer_option1", 23331,
19-
"integer option without environment variable and system property support"),
20-
BOOL("boolean_option", false, "boolean option"),
21-
BOOL0("boolean_option0", true, "boolean option without environment variable support"),
22-
BOOL1("boolean_option1", false,
23-
"boolean option without environment variable and system property support");
24-
25-
private final String key;
26-
private final Serializable defaultValue;
27-
private final Class<? extends Serializable> clazz;
28-
private final String description;
29-
30-
<T extends Serializable> ClickHouseTestOption(String key, T defaultValue, String description) {
31-
this.key = ClickHouseChecker.nonNull(key, "key");
32-
this.defaultValue = defaultValue;
33-
this.clazz = defaultValue.getClass();
34-
this.description = ClickHouseChecker.nonNull(description, "description");
35-
}
36-
37-
@Override
38-
public String getKey() {
39-
return key;
40-
}
41-
42-
@Override
43-
public Serializable getDefaultValue() {
44-
return defaultValue;
45-
}
46-
47-
@Override
48-
public Class<? extends Serializable> getValueType() {
49-
return clazz;
50-
}
51-
52-
@Override
53-
public String getDescription() {
54-
return description;
55-
}
11+
static enum ClickHouseTestOption implements ClickHouseOption {
12+
STR("string_option", "string", "string option"),
13+
STR0("string_option0", "string0", "string option without environment variable support"),
14+
STR1("string_option0", "string1",
15+
"string option without environment variable and system property support"),
16+
INT("integer_option", 2333, "integer option"),
17+
INT0("integer_option0", 23330, "integer option without environment variable support"),
18+
INT1("integer_option1", 23331,
19+
"integer option without environment variable and system property support"),
20+
BOOL("boolean_option", false, "boolean option"),
21+
BOOL0("boolean_option0", true, "boolean option without environment variable support"),
22+
BOOL1("boolean_option1", false,
23+
"boolean option without environment variable and system property support");
24+
25+
private final String key;
26+
private final Serializable defaultValue;
27+
private final Class<? extends Serializable> clazz;
28+
private final String description;
29+
30+
<T extends Serializable> ClickHouseTestOption(String key, T defaultValue, String description) {
31+
this.key = ClickHouseChecker.nonNull(key, "key");
32+
this.defaultValue = defaultValue;
33+
this.clazz = defaultValue.getClass();
34+
this.description = ClickHouseChecker.nonNull(description, "description");
5635
}
5736

58-
@Test(groups = { "unit" })
59-
public void testFromString() {
60-
Assert.assertThrows(IllegalArgumentException.class,
61-
() -> ClickHouseOption.fromString(null, String.class));
62-
Assert.assertEquals(ClickHouseOption.fromString("", String.class), "");
63-
64-
Assert.assertEquals(ClickHouseOption.fromString("", Boolean.class), Boolean.FALSE);
65-
Assert.assertEquals(ClickHouseOption.fromString("Yes", Boolean.class), Boolean.FALSE);
66-
Assert.assertEquals(ClickHouseOption.fromString("1", Boolean.class), Boolean.TRUE);
67-
Assert.assertEquals(ClickHouseOption.fromString("true", Boolean.class), Boolean.TRUE);
68-
Assert.assertEquals(ClickHouseOption.fromString("True", Boolean.class), Boolean.TRUE);
69-
70-
Assert.assertEquals(ClickHouseOption.fromString("", Integer.class), Integer.valueOf(0));
71-
Assert.assertEquals(ClickHouseOption.fromString("0", Integer.class), Integer.valueOf(0));
72-
Assert.assertThrows(IllegalArgumentException.class,
73-
() -> ClickHouseOption.fromString(null, Integer.class));
74-
75-
Assert.assertEquals(ClickHouseOption.fromString("0.1", Float.class), Float.valueOf(0.1F));
76-
Assert.assertEquals(ClickHouseOption.fromString("NaN", Float.class), Float.valueOf(Float.NaN));
77-
78-
Assert.assertEquals(ClickHouseOption.fromString("Map", ClickHouseDataType.class),
79-
ClickHouseDataType.Map);
80-
Assert.assertEquals(ClickHouseOption.fromString("RowBinary", ClickHouseFormat.class),
81-
ClickHouseFormat.RowBinary);
82-
Assert.assertThrows(IllegalArgumentException.class,
83-
() -> ClickHouseOption.fromString("NonExistFormat", ClickHouseFormat.class));
37+
@Override
38+
public String getKey() {
39+
return key;
8440
}
8541

86-
@Test(groups = { "unit" })
87-
public void testGetEffectiveDefaultValue() {
88-
// environment variables are set in pom.xml
89-
Assert.assertEquals(ClickHouseTestOption.STR.getEffectiveDefaultValue(),
90-
ClickHouseTestOption.STR.getDefaultValueFromEnvVar().get());
91-
Assert.assertEquals(ClickHouseTestOption.INT.getEffectiveDefaultValue(),
92-
Integer.parseInt(ClickHouseTestOption.INT.getDefaultValueFromEnvVar().get()));
93-
Assert.assertEquals(ClickHouseTestOption.BOOL.getEffectiveDefaultValue(),
94-
Boolean.valueOf(ClickHouseTestOption.BOOL.getDefaultValueFromEnvVar().get()));
95-
96-
String sv = "system.property";
97-
int iv = 12345;
98-
boolean bv = true;
99-
System.setProperty(ClickHouseTestOption.STR0.getPrefix().toLowerCase() + "_"
100-
+ ClickHouseTestOption.STR0.name().toLowerCase(), sv);
101-
System.setProperty(ClickHouseTestOption.INT0.getPrefix().toLowerCase() + "_"
102-
+ ClickHouseTestOption.INT0.name().toLowerCase(), String.valueOf(iv));
103-
System.setProperty(ClickHouseTestOption.BOOL0.getPrefix().toLowerCase() + "_"
104-
+ ClickHouseTestOption.BOOL0.name().toLowerCase(), String.valueOf(bv));
105-
106-
Assert.assertEquals(ClickHouseTestOption.STR0.getEffectiveDefaultValue(), sv);
107-
Assert.assertEquals(ClickHouseTestOption.INT0.getEffectiveDefaultValue(), iv);
108-
Assert.assertEquals(ClickHouseTestOption.BOOL0.getEffectiveDefaultValue(), bv);
109-
110-
Assert.assertEquals(ClickHouseTestOption.STR1.getEffectiveDefaultValue(),
111-
ClickHouseTestOption.STR1.getDefaultValue());
112-
Assert.assertEquals(ClickHouseTestOption.INT1.getEffectiveDefaultValue(),
113-
ClickHouseTestOption.INT1.getDefaultValue());
114-
Assert.assertEquals(ClickHouseTestOption.BOOL1.getEffectiveDefaultValue(),
115-
ClickHouseTestOption.BOOL1.getDefaultValue());
42+
@Override
43+
public Serializable getDefaultValue() {
44+
return defaultValue;
11645
}
46+
47+
@Override
48+
public Class<? extends Serializable> getValueType() {
49+
return clazz;
50+
}
51+
52+
@Override
53+
public String getDescription() {
54+
return description;
55+
}
56+
}
57+
58+
@Test(groups = { "unit" })
59+
public void testFromString() {
60+
Assert.assertThrows(IllegalArgumentException.class,
61+
() -> ClickHouseOption.fromString(null, String.class));
62+
Assert.assertEquals(ClickHouseOption.fromString("", String.class), "");
63+
64+
Assert.assertEquals(ClickHouseOption.fromString("", Boolean.class), Boolean.FALSE);
65+
Assert.assertEquals(ClickHouseOption.fromString("Yes", Boolean.class), Boolean.FALSE);
66+
Assert.assertEquals(ClickHouseOption.fromString("1", Boolean.class), Boolean.TRUE);
67+
Assert.assertEquals(ClickHouseOption.fromString("true", Boolean.class), Boolean.TRUE);
68+
Assert.assertEquals(ClickHouseOption.fromString("True", Boolean.class), Boolean.TRUE);
69+
70+
Assert.assertEquals(ClickHouseOption.fromString("", Integer.class), Integer.valueOf(0));
71+
Assert.assertEquals(ClickHouseOption.fromString("0", Integer.class), Integer.valueOf(0));
72+
Assert.assertThrows(IllegalArgumentException.class,
73+
() -> ClickHouseOption.fromString(null, Integer.class));
74+
75+
Assert.assertEquals(ClickHouseOption.fromString("0.1", Float.class), Float.valueOf(0.1F));
76+
Assert.assertEquals(ClickHouseOption.fromString("NaN", Float.class), Float.valueOf(Float.NaN));
77+
78+
Assert.assertEquals(ClickHouseOption.fromString("Map", ClickHouseDataType.class),
79+
ClickHouseDataType.Map);
80+
Assert.assertEquals(ClickHouseOption.fromString("RowBinary", ClickHouseFormat.class),
81+
ClickHouseFormat.RowBinary);
82+
Assert.assertThrows(IllegalArgumentException.class,
83+
() -> ClickHouseOption.fromString("NonExistFormat", ClickHouseFormat.class));
84+
}
85+
86+
@Test(groups = { "unit" })
87+
public void testGetEffectiveDefaultValue() {
88+
// environment variables are set in pom.xml
89+
Assert.assertEquals(ClickHouseTestOption.STR.getEffectiveDefaultValue(),
90+
ClickHouseTestOption.STR.getDefaultValueFromEnvVar().get());
91+
Assert.assertEquals(ClickHouseTestOption.INT.getEffectiveDefaultValue(),
92+
Integer.parseInt(ClickHouseTestOption.INT.getDefaultValueFromEnvVar().get()));
93+
Assert.assertEquals(ClickHouseTestOption.BOOL.getEffectiveDefaultValue(),
94+
Boolean.valueOf(ClickHouseTestOption.BOOL.getDefaultValueFromEnvVar().get()));
95+
96+
String sv = "system.property";
97+
int iv = 12345;
98+
boolean bv = true;
99+
System.setProperty(ClickHouseTestOption.STR0.getPrefix().toLowerCase() + "_"
100+
+ ClickHouseTestOption.STR0.name().toLowerCase(), sv);
101+
System.setProperty(ClickHouseTestOption.INT0.getPrefix().toLowerCase() + "_"
102+
+ ClickHouseTestOption.INT0.name().toLowerCase(), String.valueOf(iv));
103+
System.setProperty(ClickHouseTestOption.BOOL0.getPrefix().toLowerCase() + "_"
104+
+ ClickHouseTestOption.BOOL0.name().toLowerCase(), String.valueOf(bv));
105+
106+
Assert.assertEquals(ClickHouseTestOption.STR0.getEffectiveDefaultValue(), sv);
107+
Assert.assertEquals(ClickHouseTestOption.INT0.getEffectiveDefaultValue(), iv);
108+
Assert.assertEquals(ClickHouseTestOption.BOOL0.getEffectiveDefaultValue(), bv);
109+
110+
Assert.assertEquals(ClickHouseTestOption.STR1.getEffectiveDefaultValue(),
111+
ClickHouseTestOption.STR1.getDefaultValue());
112+
Assert.assertEquals(ClickHouseTestOption.INT1.getEffectiveDefaultValue(),
113+
ClickHouseTestOption.INT1.getDefaultValue());
114+
Assert.assertEquals(ClickHouseTestOption.BOOL1.getEffectiveDefaultValue(),
115+
ClickHouseTestOption.BOOL1.getDefaultValue());
116+
}
117117
}

0 commit comments

Comments
 (0)