File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
java-checks-test-sources/default/src/test/java/checks/tests
java-frontend/src/test/java/org/sonar/java/model Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 77class SpringBootSanityTest {
88 // Compliant, first time we encounter a spring sanity test
99 @ Test
10- void contextLoads () {}
10+ void contextLoads () {
11+ }
1112
1213 // Noncompliant@+2
1314 @ Test
Original file line number Diff line number Diff line change 1616 */
1717package org .sonar .java .model ;
1818
19+ import java .util .Optional ;
1920import org .junit .jupiter .api .Test ;
2021import org .junit .jupiter .params .ParameterizedTest ;
2122import org .junit .jupiter .params .provider .ValueSource ;
23+ import org .sonar .api .config .Configuration ;
2224import org .sonar .plugins .java .api .JavaVersion ;
2325
2426import static org .assertj .core .api .Assertions .assertThat ;
27+ import static org .mockito .Mockito .doReturn ;
28+ import static org .mockito .Mockito .mock ;
2529
2630class JavaVersionImplTest {
2731
@@ -182,5 +186,16 @@ void test_fromMap() {
182186 assertThat (version .asInt ()).isEqualTo (-1 );
183187 assertThat (version .arePreviewFeaturesEnabled ()).isFalse ();
184188 }
189+
190+ @ Test
191+ void test_preview_features_without_max_version_from_config (){
192+ var config = mock (Configuration .class );
193+ doReturn (Optional .of ("17" )).when (config ).get (JavaVersion .SOURCE_VERSION );
194+ doReturn (Optional .of ("true" )).when (config ).get (JavaVersion .ENABLE_PREVIEW );
195+ var javaVersion = JavaVersionImpl .readFromConfiguration (config );
196+ assertThat (javaVersion .asInt ()).isEqualTo (17 );
197+ // Preview features should be disabled because 17 is not the max supported version
198+ assertThat (javaVersion .arePreviewFeaturesEnabled ()).isFalse ();
199+ }
185200
186201}
You can’t perform that action at this time.
0 commit comments