diff --git a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java index 6eb6f35496..80f88f547f 100644 --- a/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java +++ b/irs-edc-client/src/main/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionService.java @@ -114,6 +114,7 @@ public boolean policyDefinitionExists(final String policyName) throws GetEdcPoli } catch (HttpClientErrorException e) { if (e.getStatusCode().value() == HttpStatus.NOT_FOUND.value()) { log.info(String.format("Policy with id %s not found within the edc", policyName)); + return false; } else { throw new GetEdcPolicyDefinitionException(e); } diff --git a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java index 5d36e0b1f1..66d59878c9 100644 --- a/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java +++ b/irs-edc-client/src/test/java/org/eclipse/tractusx/irs/edc/client/policy/service/EdcPolicyDefinitionServiceTest.java @@ -156,7 +156,7 @@ void givenPolicyName_WhenGetPolicy_ThenNotExists() throws GetEdcPolicyDefinition String policyName = "policyName"; when(endpointConfig.getPolicyDefinition()).thenReturn("/management/v2/policydefinitions" + "/" + policyName); - ResponseEntity responseEntity = ResponseEntity.badRequest().build(); + ResponseEntity responseEntity = ResponseEntity.notFound().build(); when(restTemplate.getForEntity(anyString(), eq(String.class))).thenReturn(responseEntity); // when