-
Version used
SonarQube Community EditionVersion 9.2.4 (build 50792)
SonarLint 7.1 in Eclipse -
Minimal code sample
Rule java:S2699 does not detect the “andExpect” in this sample:
@Test
public void getUsersFavorites_wrongToken() throws Exception {
mockMvc.perform(post("/statistics/favorite-contracts") //
.content(asJson(Set.of(userMe.getId(), userClarkKent.getId())))//
.headers(token("contracts.assign")) //
.contentType(MediaType.APPLICATION_JSON)) //
.andExpect(status().isForbidden());
}
although it detects it when we simplify the “headers” part like this:
private HttpHeaders tokenContractsAssign() {
return token("contracts.assign");
}
@Test
public void getUsersFavorites_wrongToken() throws Exception {
mockMvc.perform(post("/statistics/favorite-contracts") //
.content(asJson(Set.of(userMe.getId(), userClarkKent.getId())))//
.headers(tokenContractsAssign()) //
.contentType(MediaType.APPLICATION_JSON)) //
.andExpect(status().isForbidden());
}
Could you address this? Thanks in advance!