From 0028ae0cd28db4d5b64c9fb81d679d9897e1d61d Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 3 Apr 2025 17:01:17 +0200 Subject: [PATCH] ISSUE #20570: allow incident to be set to new from any points (#20585) * fix: allow incident to be set to new from any points * fix: added test back --- .../TestCaseResolutionStatusRepository.java | 29 ------------------- .../dqtests/TestCaseResourceTest.java | 11 ++----- 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java index 7fb596d0b5a..2ac68b9dfda 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/TestCaseResolutionStatusRepository.java @@ -155,32 +155,6 @@ public class TestCaseResolutionStatusRepository return JsonUtils.readValue(jsonThread, Thread.class); } - /** - * Ensure we are following the correct status flow - */ - private void validateStatus( - TestCaseResolutionStatusTypes lastStatus, TestCaseResolutionStatusTypes newStatus) { - switch (lastStatus) { - case New -> { - /* New can go to any status */ - } - case Ack -> { - if (newStatus.equals(TestCaseResolutionStatusTypes.New)) { - throw IncidentManagerException.invalidStatus(lastStatus, newStatus); - } - } - case Assigned -> { - if (List.of(TestCaseResolutionStatusTypes.New, TestCaseResolutionStatusTypes.Ack) - .contains(newStatus)) { - throw IncidentManagerException.invalidStatus(lastStatus, newStatus); - } - } - // We only validate status if the last one is unresolved, so we should - // never land here - default -> throw IncidentManagerException.invalidStatus(lastStatus, newStatus); - } - } - @Override @Transaction public void storeInternal( @@ -195,9 +169,6 @@ public class TestCaseResolutionStatusRepository // if we have an ongoing incident, set the stateId if the new record to be created // and validate the flow if (Boolean.TRUE.equals(unresolvedIncident(lastIncident))) { - validateStatus( - lastIncident.getTestCaseResolutionStatusType(), - recordEntity.getTestCaseResolutionStatusType()); // If there is an unresolved incident update the state ID recordEntity.setStateId(lastIncident.getStateId()); // If the last incident had a severity assigned and the incoming incident does not, inherit diff --git a/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResourceTest.java b/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResourceTest.java index 6a204ef131a..b2567f2463b 100644 --- a/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResourceTest.java +++ b/openmetadata-service/src/test/java/org/openmetadata/service/resources/dqtests/TestCaseResourceTest.java @@ -1820,7 +1820,7 @@ public class TestCaseResourceTest extends EntityResourceTest - createTestCaseFailureStatus( - createAssignedIncident.withTestCaseResolutionStatusType( - TestCaseResolutionStatusTypes.Ack)), - BAD_REQUEST, - "Incident with status [Assigned] cannot be moved to [Ack]"); + createTestCaseFailureStatus( + createAssignedIncident.withTestCaseResolutionStatusType(TestCaseResolutionStatusTypes.Ack)); } @Test