diff --git a/DEPENDENCIES b/DEPENDENCIES index 16a628749..58e5109b3 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -9,8 +9,8 @@ maven/mavencentral/com.azure/azure-core-http-netty/1.13.5, MIT AND Apache-2.0, a maven/mavencentral/com.azure/azure-core/1.39.0, MIT, approved, clearlydefined maven/mavencentral/com.azure/azure-core/1.40.0, MIT, approved, clearlydefined maven/mavencentral/com.azure/azure-core/1.41.0, MIT AND Apache-2.0, approved, #9648 -maven/mavencentral/com.azure/azure-identity/1.9.0, MIT, approved, clearlydefined -maven/mavencentral/com.azure/azure-identity/1.9.2, , restricted, clearlydefined +maven/mavencentral/com.azure/azure-identity/1.9.0, MIT AND Apache-2.0, approved, #9686 +maven/mavencentral/com.azure/azure-identity/1.9.2, MIT AND Apache-2.0, approved, #9686 maven/mavencentral/com.azure/azure-json/1.0.1, MIT AND Apache-2.0, approved, #7933 maven/mavencentral/com.azure/azure-security-keyvault-secrets/4.6.2, MIT, approved, #7940 maven/mavencentral/com.azure/azure-security-keyvault-secrets/4.6.3, MIT, approved, #7940 @@ -162,8 +162,8 @@ maven/mavencentral/io.netty/netty-transport/4.1.94.Final, Apache-2.0 AND BSD-3-C maven/mavencentral/io.opentelemetry.instrumentation/opentelemetry-instrumentation-annotations/1.27.0, Apache-2.0, approved, #9270 maven/mavencentral/io.opentelemetry/opentelemetry-api/1.27.0, Apache-2.0, approved, clearlydefined maven/mavencentral/io.opentelemetry/opentelemetry-context/1.27.0, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.projectreactor.netty/reactor-netty-core/1.0.28, Apache-2.0, approved, clearlydefined -maven/mavencentral/io.projectreactor.netty/reactor-netty-core/1.0.33, , restricted, clearlydefined +maven/mavencentral/io.projectreactor.netty/reactor-netty-core/1.0.28, Apache-2.0, approved, #9687 +maven/mavencentral/io.projectreactor.netty/reactor-netty-core/1.0.33, Apache-2.0, approved, #9687 maven/mavencentral/io.projectreactor.netty/reactor-netty-http/1.0.28, Apache-2.0, approved, clearlydefined maven/mavencentral/io.projectreactor.netty/reactor-netty-http/1.0.33, Apache-2.0, approved, clearlydefined maven/mavencentral/io.projectreactor/reactor-core/3.4.27, Apache-2.0, approved, #7517 diff --git a/core/edr-core/src/main/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImpl.java b/core/edr-core/src/main/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImpl.java index 363021271..0a6fe2a33 100644 --- a/core/edr-core/src/main/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImpl.java +++ b/core/edr-core/src/main/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImpl.java @@ -134,11 +134,6 @@ protected void transitionToNegotiated(EndpointDataReferenceEntry edrEntry) { update(edrEntry); } - protected void transitionToExpired(EndpointDataReferenceEntry edrEntry) { - edrEntry.transitionToExpired(); - update(edrEntry); - } - protected void transitionToError(EndpointDataReferenceEntry edrEntry, String message) { edrEntry.setErrorDetail(message); edrEntry.transitionError(); diff --git a/core/edr-core/src/test/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImplTest.java b/core/edr-core/src/test/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImplTest.java index 769c1b318..ba572b6bb 100644 --- a/core/edr-core/src/test/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImplTest.java +++ b/core/edr-core/src/test/java/org/eclipse/tractusx/edc/edr/core/manager/EdrManagerImplTest.java @@ -24,6 +24,7 @@ import org.eclipse.edc.service.spi.result.ServiceResult; import org.eclipse.edc.spi.monitor.Monitor; import org.eclipse.edc.spi.query.Criterion; +import org.eclipse.edc.spi.query.QuerySpec; import org.eclipse.edc.spi.result.StoreResult; import org.eclipse.tractusx.edc.edr.spi.store.EndpointDataReferenceCache; import org.eclipse.tractusx.edc.edr.spi.types.EndpointDataReferenceEntry; @@ -38,16 +39,19 @@ import java.time.ZoneOffset; import java.util.List; import java.util.UUID; +import java.util.stream.Stream; import static java.util.Collections.emptyList; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; import static org.eclipse.edc.connector.transfer.spi.types.TransferProcess.Type.CONSUMER; import static org.eclipse.edc.spi.persistence.StateEntityStore.hasState; +import static org.eclipse.tractusx.edc.edr.core.EdrCoreExtension.DEFAULT_BATCH_SIZE; import static org.eclipse.tractusx.edc.edr.core.EdrCoreExtension.DEFAULT_EXPIRING_DURATION; import static org.eclipse.tractusx.edc.edr.core.fixtures.TestFunctions.getContractNegotiation; import static org.eclipse.tractusx.edc.edr.core.fixtures.TestFunctions.getNegotiateEdrRequest; import static org.eclipse.tractusx.edc.edr.core.manager.EdrManagerImpl.LOCAL_CALLBACK; +import static org.eclipse.tractusx.edc.edr.spi.types.EndpointDataReferenceEntryStates.DELETING; import static org.eclipse.tractusx.edc.edr.spi.types.EndpointDataReferenceEntryStates.ERROR; import static org.eclipse.tractusx.edc.edr.spi.types.EndpointDataReferenceEntryStates.EXPIRED; import static org.eclipse.tractusx.edc.edr.spi.types.EndpointDataReferenceEntryStates.NEGOTIATED; @@ -193,8 +197,8 @@ void initial_shouldNotTransitionError_whenInitiatedTransferFailsOnce() { } @Test - @DisplayName("Verify that EDR is deleted when the retention period is over") - void initial_shouldDeleteTheEntry_whenTheRetentionPeriodIsOver() { + @DisplayName("Verify that EDR state should transition to deleting when the retention period is over") + void initial_shouldTransitionToDeleting_whenTheRetentionPeriodIsOver() { var expiration = Instant.now().atOffset(ZoneOffset.UTC).toInstant().minusSeconds(DEFAULT_EXPIRING_DURATION + 10); var edrEntry = edrEntryBuilder().state(EXPIRED.code()).expirationTimestamp(expiration.toEpochMilli()).build(); @@ -202,7 +206,28 @@ void initial_shouldDeleteTheEntry_whenTheRetentionPeriodIsOver() { .thenReturn(List.of(edrEntry)) .thenReturn(emptyList()); - when(edrCache.deleteByTransferProcessId(edrEntry.getTransferProcessId())).thenReturn(StoreResult.success(edrEntry)); + edrManager.start(); + + await().untilAsserted(() -> verify(edrCache).update(argThat(p -> p.getState() == DELETING.code()))); + } + + @Test + @DisplayName("Verify that EDR is deleted when state is DELETING") + void initial_shouldDeleteTheEntry_whenTheRetentionPeriodIsOver() { + var expiration = Instant.now().atOffset(ZoneOffset.UTC).toInstant().minusSeconds(DEFAULT_EXPIRING_DURATION + 10); + var edrEntry = edrEntryBuilder().state(DELETING.code()).expirationTimestamp(expiration.toEpochMilli()).build(); + + var query = QuerySpec.Builder.newInstance() + .filter(hasState(DELETING.code())) + .limit(DEFAULT_BATCH_SIZE) + .build(); + + when(edrCache.queryForEntries(query)) + .thenReturn(Stream.of(edrEntry)) + .thenReturn(Stream.empty()); + + + when(edrCache.deleteByTransferProcessId(edrEntry.getTransferProcessId())).thenReturn(StoreResult.success()); edrManager.start();