4545import org .sonar .api .batch .rule .Checks ;
4646import org .sonar .api .batch .rule .internal .ActiveRulesBuilder ;
4747import org .sonar .api .batch .rule .internal .NewActiveRule ;
48+ import org .sonar .api .batch .sensor .internal .DefaultSensorDescriptor ;
4849import org .sonar .api .batch .sensor .internal .SensorContextTester ;
4950import org .sonar .api .config .Configuration ;
5051import org .sonar .api .config .internal .MapSettings ;
@@ -112,8 +113,8 @@ void test_toString() throws IOException {
112113
113114 @ Test
114115 void test_issues_creation_on_main_file () throws IOException {
115- // Expected issues : the number of methods violating BadMethodName rule. Currently, 17 tests.
116- testIssueCreation (InputFile .Type .MAIN , 17 );
116+ // Expected issues : the number of methods violating BadMethodName rule. Currently, 18 tests.
117+ testIssueCreation (InputFile .Type .MAIN , 18 );
117118 }
118119
119120 @ Test
@@ -132,8 +133,8 @@ private void testIssueCreation(InputFile.Type onType, int expectedIssues) throws
132133 JavaSensor jss = new JavaSensor (sonarComponents , fs , javaResourceLocator , settings .asConfig (), noSonarFilter , null );
133134
134135 jss .execute (context );
135- // argument 120 refers to the comment on line #120 in this file
136- verify (noSonarFilter , times (1 )).noSonarInFile (fs .inputFiles ().iterator ().next (), Collections .singleton (120 ));
136+ // argument 121 refers to the comment on line #121 in this file, each time this file changes, this argument should be updated
137+ verify (noSonarFilter , times (1 )).noSonarInFile (fs .inputFiles ().iterator ().next (), Collections .singleton (121 ));
137138 verify (sonarComponents , times (expectedIssues )).reportIssue (any (AnalyzerMessage .class ));
138139
139140 settings .setProperty (JavaVersion .SOURCE_VERSION , "wrongFormat" );
@@ -434,6 +435,16 @@ void filter_checks_when_autoscan_true() throws IOException {
434435 );
435436 }
436437
438+ @ Test
439+ void test_describe_sensor () throws IOException {
440+ DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor ();
441+ SonarComponents sonarComponents = createSonarComponentsMock (createContext (InputFile .Type .MAIN ));
442+ var sensor = new JavaSensor (sonarComponents , null , null , null , null , null );
443+ sensor .describe (descriptor );
444+ assertThat (descriptor .name ()).isEqualTo ("JavaSensor" );
445+ assertThat (descriptor .languages ()).containsExactly ("java" , "jsp" );
446+ }
447+
437448 private SensorContextTester analyzeTwoFilesWithIssues (MapSettings settings ) throws IOException {
438449 SensorContextTester context = SensorContextTester .create (new File ("src/test/files" ).getAbsoluteFile ())
439450 .setSettings (settings )
0 commit comments