]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16397 fix show hotspot API endpoint's payload
authorAurelien Poscia <aurelien.poscia@sonarsource.com>
Tue, 31 May 2022 15:51:17 +0000 (17:51 +0200)
committersonartech <sonartech@sonarsource.com>
Wed, 1 Jun 2022 20:03:02 +0000 (20:03 +0000)
server/sonar-webserver-webapi/src/main/java/org/sonar/server/hotspot/ws/ShowAction.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/ShowActionTest.java

index 44d5df3186ff495ce226f89857bac9d5be424546..33207c9977f3e3a4f1fdd8a0502226c42cf46a6e 100644 (file)
@@ -183,8 +183,8 @@ public class ShowAction implements HotspotsWsAction {
 
     Map<String, String> sectionKeyToContent = getSectionKeyToContent(ruleDto);
     Optional.ofNullable(sectionKeyToContent.get(DEFAULT_KEY)).ifPresent(ruleBuilder::setRiskDescription);
-    Optional.ofNullable(sectionKeyToContent.get(ROOT_CAUSE_SECTION_KEY)).ifPresent(ruleBuilder::setVulnerabilityDescription);
-    Optional.ofNullable(sectionKeyToContent.get(ASSESS_THE_PROBLEM_SECTION_KEY)).ifPresent(ruleBuilder::setRiskDescription);
+    Optional.ofNullable(sectionKeyToContent.get(ROOT_CAUSE_SECTION_KEY)).ifPresent(ruleBuilder::setRiskDescription);
+    Optional.ofNullable(sectionKeyToContent.get(ASSESS_THE_PROBLEM_SECTION_KEY)).ifPresent(ruleBuilder::setVulnerabilityDescription);
     Optional.ofNullable(sectionKeyToContent.get(HOW_TO_FIX_SECTION_KEY)).ifPresent(ruleBuilder::setFixRecommendations);
     responseBuilder.setRule(ruleBuilder.build());
   }
index 1cc2d5d8a0ce030e5b271fdaf2c750fefa720d01..47d26b88f0c0036ec7e27b43e972128c2e3e14f1 100644 (file)
@@ -464,8 +464,8 @@ public class ShowActionTest {
     Hotspots.ShowWsResponse response = newRequest(hotspot)
       .executeProtobuf(Hotspots.ShowWsResponse.class);
 
-    assertThat(response.getRule().getVulnerabilityDescription()).isEqualTo(rootCauseSection.getContent());
-    assertThat(response.getRule().getRiskDescription()).isEqualTo(assesTheProblemSection.getContent());
+    assertThat(response.getRule().getRiskDescription()).isEqualTo(rootCauseSection.getContent());
+    assertThat(response.getRule().getVulnerabilityDescription()).isEqualTo(assesTheProblemSection.getContent());
     assertThat(response.getRule().getFixRecommendations()).isEqualTo(howToFixSection.getContent());
   }
 
@@ -516,8 +516,8 @@ public class ShowActionTest {
     Hotspots.ShowWsResponse response = newRequest(hotspot)
       .executeProtobuf(Hotspots.ShowWsResponse.class);
 
-    assertThat(response.getRule().getVulnerabilityDescription()).isEqualTo(rootCauseSection.getContent());
-    assertThat(response.getRule().getRiskDescription()).isEqualTo(assesTheProblemSection.getContent());
+    assertThat(response.getRule().getRiskDescription()).isEqualTo(rootCauseSection.getContent());
+    assertThat(response.getRule().getVulnerabilityDescription()).isEqualTo(assesTheProblemSection.getContent());
     assertThat(response.getRule().getFixRecommendations()).isEmpty();
   }
 
@@ -540,7 +540,7 @@ public class ShowActionTest {
 
     RuleDescriptionSectionDto sectionDto = RuleDescriptionSectionDto.builder()
       .uuid(uuidFactory.create())
-      .key(ASSESS_THE_PROBLEM_SECTION_KEY)
+      .key(DEFAULT_KEY)
       .content(description)
       .build();