From c7c20741bd5055beece091e981789aea1a15f401 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 21 May 2019 17:50:50 +0200 Subject: [PATCH] SONAR-12026 Update status names, transition names and description * Replace INREVIEW and TOREVIEW to IN_REVIEW and TO_REVIEW * Update transition names and descriptions --- .../v78/UpdateSecurityHotspotsStatuses.java | 4 ++-- .../UpdateSecurityHotspotsStatusesTest.java | 18 +++++++++--------- .../org/sonar/server/issue/workflow/State.java | 2 -- .../sonar/server/issue/workflow/StateTest.java | 10 +--------- .../issue/ws/SearchActionFacetsTest.java | 6 +++--- .../js/apps/issues/sidebar/StatusFacet.tsx | 2 +- .../sidebar/__tests__/StatusFacet-test.tsx | 10 +++++----- .../__snapshots__/StatusFacet-test.tsx.snap | 16 ++++++++-------- .../resources/org/sonar/l10n/core.properties | 14 +++++++------- .../main/java/org/sonar/api/issue/Issue.java | 4 ++-- 10 files changed, 38 insertions(+), 48 deletions(-) diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java index 8cd5db78a77..ca988261401 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatuses.java @@ -45,8 +45,8 @@ public class UpdateSecurityHotspotsStatuses extends DataChange { private static final String STATUS_REOPENED = "REOPENED"; private static final String STATUS_RESOLVED = "RESOLVED"; - private static final String STATUS_TO_REVIEW = "TOREVIEW"; - private static final String STATUS_IN_REVIEW = "INREVIEW"; + private static final String STATUS_TO_REVIEW = "TO_REVIEW"; + private static final String STATUS_IN_REVIEW = "IN_REVIEW"; private static final String STATUS_REVIEWED = "REVIEWED"; private static final int RULE_TYPE_SECURITY_HOTSPOT = 4; diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java index cefd7097832..a3b10a97883 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v78/UpdateSecurityHotspotsStatusesTest.java @@ -68,8 +68,8 @@ public class UpdateSecurityHotspotsStatusesTest { underTest.execute(); assertIssues( - tuple(issue1, "TOREVIEW", null, 4, NOW), - tuple(issue2, "TOREVIEW", null, 4, NOW), + tuple(issue1, "TO_REVIEW", null, 4, NOW), + tuple(issue2, "TO_REVIEW", null, 4, NOW), // Not updated tuple(issue3, "OPEN", null, 1, PAST), tuple(issue4, "REOPENED", null, 2, PAST), @@ -89,7 +89,7 @@ public class UpdateSecurityHotspotsStatusesTest { underTest.execute(); assertIssues( - tuple(issue1, "INREVIEW", null, 4, NOW), + tuple(issue1, "IN_REVIEW", null, 4, NOW), tuple(issue2, "REVIEWED", "FIXED", 4, NOW), // Not updated tuple(issue3, "RESOLVED", "FIXED", 1, PAST), @@ -109,8 +109,8 @@ public class UpdateSecurityHotspotsStatusesTest { underTest.execute(); assertIssueChanges( - tuple(issue1, "diff", "status=REOPENED|TOREVIEW,resolution=", NOW, NOW, NOW), - tuple(issue3, "diff", "status=RESOLVED|INREVIEW,resolution=FIXED|", NOW, NOW, NOW), + tuple(issue1, "diff", "status=REOPENED|TO_REVIEW,resolution=", NOW, NOW, NOW), + tuple(issue3, "diff", "status=RESOLVED|IN_REVIEW,resolution=FIXED|", NOW, NOW, NOW), tuple(issue4, "diff", "status=RESOLVED|REVIEWED,resolution=WONTFIX|FIXED", NOW, NOW, NOW)); } @@ -159,15 +159,15 @@ public class UpdateSecurityHotspotsStatusesTest { underTest.execute(); assertIssues( - tuple(issue1, "TOREVIEW", null, 4, NOW), - tuple(issue2, "TOREVIEW", null, 4, NOW)); + tuple(issue1, "TO_REVIEW", null, 4, NOW), + tuple(issue2, "TO_REVIEW", null, 4, NOW)); // Set a new date for NOW in order to check that issues has not been updated again system2.setNow(NOW + 1_000_000_000L); underTest.execute(); assertIssues( - tuple(issue1, "TOREVIEW", null, 4, NOW), - tuple(issue2, "TOREVIEW", null, 4, NOW)); + tuple(issue1, "TO_REVIEW", null, 4, NOW), + tuple(issue2, "TO_REVIEW", null, 4, NOW)); } @Test diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/State.java b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/State.java index 7cd8d5308f3..5d2405f8f38 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/State.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/issue/workflow/State.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; import javax.annotation.CheckForNull; -import org.apache.commons.lang.StringUtils; import org.sonar.api.issue.Issue; public class State { @@ -36,7 +35,6 @@ public class State { public State(String key, Transition[] outTransitions) { Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "State key must be set"); - Preconditions.checkArgument(StringUtils.isAllUpperCase(key), "State key must be upper-case"); checkDuplications(outTransitions, key); this.key = key; diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/StateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/StateTest.java index 8793705984f..0e7c438bad9 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/StateTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/StateTest.java @@ -28,7 +28,7 @@ public class StateTest { @Rule public ExpectedException expectedException = ExpectedException.none(); - Transition t1 = Transition.builder("close").from("OPEN").to("CLOSED").build(); + private Transition t1 = Transition.builder("close").from("OPEN").to("CLOSED").build(); @Test public void key_should_be_set() { @@ -38,14 +38,6 @@ public class StateTest { new State("", new Transition[0]); } - @Test - public void key_should_be_upper_case() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("State key must be upper-case"); - - new State("close", new Transition[0]); - } - @Test public void no_duplicated_out_transitions() { expectedException.expect(IllegalArgumentException.class); diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java index 8ef8027a667..1d5d65750a9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionFacetsTest.java @@ -115,7 +115,7 @@ public class SearchActionFacetsTest { .executeProtobuf(SearchWsResponse.class); Map expectedStatuses = ImmutableMap.builder().put("OPEN", 1L).put("CONFIRMED", 0L) - .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("INREVIEW", 0L).put("TOREVIEW", 0L).put("REVIEWED", 0L).build(); + .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("IN_REVIEW", 0L).put("TO_REVIEW", 0L).put("REVIEWED", 0L).build(); assertThat(response.getFacets().getFacetsList()) .extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))) @@ -153,7 +153,7 @@ public class SearchActionFacetsTest { .executeProtobuf(SearchWsResponse.class); Map expectedStatuses = ImmutableMap.builder().put("OPEN", 10L).put("CONFIRMED", 0L) - .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("INREVIEW", 0L).put("TOREVIEW", 0L).put("REVIEWED", 0L).build(); + .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("IN_REVIEW", 0L).put("TO_REVIEW", 0L).put("REVIEWED", 0L).build(); assertThat(response.getFacets().getFacetsList()) .extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))) @@ -507,7 +507,7 @@ public class SearchActionFacetsTest { .executeProtobuf(SearchWsResponse.class); Map expectedStatuses = ImmutableMap.builder().put("OPEN", 1L).put("CONFIRMED", 0L) - .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("INREVIEW", 0L).put("TOREVIEW", 0L).put("REVIEWED", 0L).build(); + .put("REOPENED", 0L).put("RESOLVED", 0L).put("CLOSED", 0L).put("IN_REVIEW", 0L).put("TO_REVIEW", 0L).put("REVIEWED", 0L).build(); assertThat(response.getFacets().getFacetsList()) .extracting(Common.Facet::getProperty, facet -> facet.getValuesList().stream().collect(toMap(FacetValue::getVal, FacetValue::getCount))) diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx index 5c0c51f433e..ea83e7a20c2 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/StatusFacet.tsx @@ -39,7 +39,7 @@ interface Props { } const STATUSES = ['OPEN', 'CONFIRMED', 'REOPENED', 'RESOLVED']; -const HOTSPOT_STATUSES = ['TOREVIEW', 'REVIEWED', 'INREVIEW']; +const HOTSPOT_STATUSES = ['TO_REVIEW', 'REVIEWED', 'IN_REVIEW']; const COMMON_STATUSES = ['CLOSED']; export default class StatusFacet extends React.PureComponent { diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StatusFacet-test.tsx b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StatusFacet-test.tsx index 6e7ee1ec10d..3b7b1482d35 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StatusFacet-test.tsx +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/StatusFacet-test.tsx @@ -35,7 +35,7 @@ it('should toggle status facet', () => { it('should clear status facet', () => { const onChange = jest.fn(); - const wrapper = shallowRender({ onChange, statuses: ['TOREVIEW'] }); + const wrapper = shallowRender({ onChange, statuses: ['TO_REVIEW'] }); wrapper.children('FacetHeader').prop('onClear')(); expect(onChange).toBeCalledWith({ statuses: [] }); }); @@ -43,8 +43,8 @@ it('should clear status facet', () => { it('should select a status', () => { const onChange = jest.fn(); const wrapper = shallowRender({ onChange }); - clickAndCheck('TOREVIEW'); - clickAndCheck('OPEN', true, ['OPEN', 'TOREVIEW']); + clickAndCheck('TO_REVIEW'); + clickAndCheck('OPEN', true, ['OPEN', 'TO_REVIEW']); clickAndCheck('CONFIRMED'); function clickAndCheck(status: string, multiple = false, expected = [status]) { @@ -70,8 +70,8 @@ function shallowRender(props: Partial = {}) { REOPENED: 0, RESOLVED: 0, CLOSED: 8, - TOREVIEW: 150, - INREVIEW: 7, + TO_REVIEW: 150, + IN_REVIEW: 7, REVIEWED: 1105 }} statuses={[]} diff --git a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/StatusFacet-test.tsx.snap b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/StatusFacet-test.tsx.snap index de473009503..9d01da1c88e 100644 --- a/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/StatusFacet-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/issues/sidebar/__tests__/__snapshots__/StatusFacet-test.tsx.snap @@ -90,17 +90,17 @@ exports[`should render correctly 1`] = ` active={false} disabled={false} halfWidth={true} - key="TOREVIEW" + key="TO_REVIEW" loading={false} name={ } onClick={[Function]} stat="150" - tooltip="issue.status.TOREVIEW" - value="TOREVIEW" + tooltip="issue.status.TO_REVIEW" + value="TO_REVIEW" /> } onClick={[Function]} stat="7" - tooltip="issue.status.INREVIEW" - value="INREVIEW" + tooltip="issue.status.IN_REVIEW" + value="IN_REVIEW" />