File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
java-frontend/src/test/java/org/sonar/java/model Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 1919import org .junit .jupiter .api .Test ;
2020import org .junit .jupiter .params .ParameterizedTest ;
2121import org .junit .jupiter .params .provider .ValueSource ;
22+ import org .sonar .api .config .Configuration ;
2223import org .sonar .plugins .java .api .JavaVersion ;
2324
2425import static org .assertj .core .api .Assertions .assertThat ;
26+ import static org .mockito .Mockito .doReturn ;
27+ import static org .mockito .Mockito .mock ;
2528
2629class JavaVersionImplTest {
2730
@@ -182,5 +185,16 @@ void test_fromMap() {
182185 assertThat (version .asInt ()).isEqualTo (-1 );
183186 assertThat (version .arePreviewFeaturesEnabled ()).isFalse ();
184187 }
188+
189+ @ Test
190+ void test_preview_features_without_max_version_from_config (){
191+ var config = mock (Configuration .class );
192+ doReturn ("17" ).when (config ).get (JavaVersion .SOURCE_VERSION );
193+ doReturn ("true" ).when (config ).get (JavaVersion .ENABLE_PREVIEW );
194+ var javaVersion = JavaVersionImpl .readFromConfiguration (config );
195+ assertThat (javaVersion .asInt ()).isEqualTo (17 );
196+ // Preview features should be disabled because 17 is not the max supported version
197+ assertThat (javaVersion .arePreviewFeaturesEnabled ()).isFalse ();
198+ }
185199
186200}
You can’t perform that action at this time.
0 commit comments