Skip to content

Commit c982361

Browse files
committed
Add PropertiesJavaFormatConfigTests
1 parent 727bda8 commit c982361

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2017-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.spring.javaformat.config;
18+
19+
import java.util.Properties;
20+
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
25+
/**
26+
* Tests for {@link PropertiesJavaFormatConfig}.
27+
*
28+
* @author Phillip Webb
29+
*/
30+
class PropertiesJavaFormatConfigTests {
31+
32+
@Test
33+
void getJavaBaselineWhenNoPropertyReturnsJava11() {
34+
Properties properties = new Properties();
35+
PropertiesJavaFormatConfig config = new PropertiesJavaFormatConfig(properties);
36+
assertThat(config.getJavaBaseline()).isEqualTo(JavaBaseline.V11);
37+
}
38+
39+
@Test
40+
void getJavaBaselineWhenPropertyReturnsPropertyValue() {
41+
Properties properties = new Properties();
42+
properties.setProperty("java-baseline", "8");
43+
PropertiesJavaFormatConfig config = new PropertiesJavaFormatConfig(properties);
44+
assertThat(config.getJavaBaseline()).isEqualTo(JavaBaseline.V8);
45+
}
46+
47+
@Test
48+
void getIndentationStyleWhenNoPropertyReturnsJava11() {
49+
Properties properties = new Properties();
50+
PropertiesJavaFormatConfig config = new PropertiesJavaFormatConfig(properties);
51+
assertThat(config.getIndentationStyle()).isEqualTo(IndentationStyle.TABS);
52+
}
53+
54+
@Test
55+
void getIndentationStyleWhenPropertyReturnsPropertyValue() {
56+
Properties properties = new Properties();
57+
properties.setProperty("indentation-style", "spaces");
58+
PropertiesJavaFormatConfig config = new PropertiesJavaFormatConfig(properties);
59+
assertThat(config.getIndentationStyle()).isEqualTo(IndentationStyle.SPACES);
60+
}
61+
62+
}

0 commit comments

Comments
 (0)