use of org.sonar.core.util.RuleChange in project sonarqube by SonarSource.
the class SonarLintClientsRegistryTest method listen_givenOneClientInterestedInJavaEvents_sendOneJavaEvent.
@Test
public void listen_givenOneClientInterestedInJavaEvents_sendOneJavaEvent() throws IOException {
Set<String> javaLanguageKey = Set.of("java");
when(defaultAsyncContext.getResponse()).thenReturn(response);
when(response.getOutputStream()).thenReturn(outputStream);
SonarLintClient sonarLintClient = new SonarLintClient(defaultAsyncContext, exampleKeys, javaLanguageKey, USER_UUID);
underTest.registerClient(sonarLintClient);
RuleChange javaRule = createRuleChange();
RuleChange[] activatedRules = { javaRule };
RuleChange[] deactivatedRules = { javaRule };
RuleSetChangedEvent ruleSetChangedEvent = new RuleSetChangedEvent(exampleKeys.toArray(String[]::new), activatedRules, deactivatedRules);
underTest.listen(ruleSetChangedEvent);
ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
verify(outputStream).write(captor.capture());
String message = new String(captor.getValue());
assertThatEvent(message).hasType("RuleSetChanged").hasJsonData(getClass().getResource("rule-change-event-data.json"));
}
Aggregations