From 2451d068fdf8768b0d7a81f648b393c1ca052388 Mon Sep 17 00:00:00 2001 From: alexsilaghi Date: Wed, 11 Dec 2024 14:35:01 +0200 Subject: [PATCH] add rollback mechanism. --- .../EntityUpdateFailedEvent.java | 36 +++++++++++++++++ .../EntityUpdateFailedEventHandler.java | 39 +++++++++++++++++++ .../events/NewRevisionsEvent.java | 8 ++-- .../events/RevisionsEvent.java | 8 +++- .../mappers/RevisionEventMapper.java | 6 +-- .../RevisionsEventRepository.java | 4 +- .../NewRevisionsEventServiceImpl.java | 1 + .../GetChangedEntitiesCommandHandlerIT.java | 5 ++- ...toryViewCommandHandlerIntegrationTest.java | 2 +- ...wRevisionsEventHandlerIntegrationTest.java | 8 ++-- .../mappers/RevisionEventMapperTest.java | 6 +-- .../NewRevisionsEventServiceTest.java | 24 ++++++------ 12 files changed, 115 insertions(+), 32 deletions(-) create mode 100644 src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEvent.java create mode 100644 src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEventHandler.java diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEvent.java new file mode 100644 index 0000000..96be8fa --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEvent.java @@ -0,0 +1,36 @@ +package edu.stanford.protege.webprotegeeventshistory; + +import com.fasterxml.jackson.annotation.JsonProperty; +import edu.stanford.protege.webprotege.common.ChangeRequestId; +import edu.stanford.protege.webprotege.common.EventId; +import edu.stanford.protege.webprotege.common.ProjectEvent; +import edu.stanford.protege.webprotege.common.ProjectId; + +import javax.annotation.Nonnull; + +public record EntityUpdateFailedEvent(@JsonProperty("projectId") ProjectId projectId, + @JsonProperty("eventId") EventId eventId, + + @JsonProperty("entityIri") String entityIri, + @JsonProperty("changeRequestId")ChangeRequestId changeRequestId) implements ProjectEvent { + + public static String CHANNEL = "webprotege.api.EntityUpdateFailed"; + + + @Nonnull + @Override + public ProjectId projectId() { + return projectId; + } + + @Nonnull + @Override + public EventId eventId() { + return eventId; + } + + @Override + public String getChannel() { + return CHANNEL; + } +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEventHandler.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEventHandler.java new file mode 100644 index 0000000..489b12e --- /dev/null +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/EntityUpdateFailedEventHandler.java @@ -0,0 +1,39 @@ +package edu.stanford.protege.webprotegeeventshistory; + + +import edu.stanford.protege.webprotege.ipc.EventHandler; +import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.repositories.RevisionsEventRepository; +import org.springframework.stereotype.Component; + +import javax.annotation.Nonnull; + +@Component +public class EntityUpdateFailedEventHandler implements EventHandler { + + private final RevisionsEventRepository repository; + + public EntityUpdateFailedEventHandler(RevisionsEventRepository repository) { + this.repository = repository; + } + + @Nonnull + @Override + public String getChannelName() { + return EntityUpdateFailedEvent.CHANNEL; + } + + @Nonnull + @Override + public String getHandlerName() { + return EntityUpdateFailedEventHandler.class.getName(); + } + + @Override + public Class getEventClass() { + return EntityUpdateFailedEvent.class; + } + @Override + public void handleEvent(EntityUpdateFailedEvent event) { + repository.deleteByChangeRequestIdAndWhoficEntityIri(event.changeRequestId().id(), event.entityIri()); + } +} diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java index 8fbf41c..1396175 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/NewRevisionsEvent.java @@ -13,15 +13,17 @@ public record NewRevisionsEvent( EventId eventId, ProjectId projectId, - Set changes + Set changes, + ChangeRequestId changeRequestId ) implements ProjectEvent { public final static String CHANNEL = "webprotege.events.projects.uiHistory.NewRevisionsEvent"; @JsonCreator public static NewRevisionsEvent create(@JsonProperty("eventId") EventId eventId, @JsonProperty("projectId") ProjectId projectId, - @JsonProperty("changes") Set changes) { - return new NewRevisionsEvent(eventId, projectId, changes); + @JsonProperty("changes") Set changes, + @JsonProperty("changeRequestId") ChangeRequestId changeRequestId) { + return new NewRevisionsEvent(eventId, projectId, changes, changeRequestId); } @Override diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/RevisionsEvent.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/RevisionsEvent.java index 9c8fe8d..42dc1c8 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/RevisionsEvent.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/events/RevisionsEvent.java @@ -1,6 +1,7 @@ package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events; import com.google.common.base.Objects; +import edu.stanford.protege.webprotege.common.ChangeRequestId; import edu.stanford.protege.webprotege.common.ProjectId; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.ChangeType; import org.springframework.data.mongodb.core.index.*; @@ -16,6 +17,8 @@ public record RevisionsEvent( String whoficEntityIri, ChangeType changeType, @Indexed(name = "timestamp", direction = IndexDirection.DESCENDING) long timestamp, + + String changeRequestId, org.bson.Document projectChange ) { @@ -29,8 +32,9 @@ public static RevisionsEvent create(ProjectId projectId, String whoficEntityIri, ChangeType changeType, long timestamp, - org.bson.Document projectChange) { - return new RevisionsEvent(projectId, whoficEntityIri, changeType, timestamp, projectChange); + org.bson.Document projectChange, + ChangeRequestId changeRequestId) { + return new RevisionsEvent(projectId, whoficEntityIri, changeType, timestamp, changeRequestId != null ? changeRequestId.id() : null, projectChange); } @Override diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapper.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapper.java index 26c192e..c579111 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapper.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapper.java @@ -21,7 +21,7 @@ public RevisionEventMapper(ObjectMapper objectMapper) { public List mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent newRevisionsEvent) { - List revisionsEvents = newRevisionsEvent.changes().stream() + return newRevisionsEvent.changes().stream() .flatMap(projectChangeForEntity -> { String whoficIri = projectChangeForEntity.whoficEntityIri(); ChangeType changeType = projectChangeForEntity.changeType(); @@ -29,10 +29,8 @@ public List mapNewRevisionsEventToRevisionsEvents(NewRevisionsEv long timestamp = projectChange.getTimestamp(); var projectChangeDocument = objectMapper.convertValue(projectChange, Document.class); - return Stream.of(RevisionsEvent.create(newRevisionsEvent.projectId(), whoficIri, changeType, timestamp, projectChangeDocument)); + return Stream.of(RevisionsEvent.create(newRevisionsEvent.projectId(), whoficIri, changeType, timestamp, projectChangeDocument, newRevisionsEvent.changeRequestId())); }) .toList(); - - return revisionsEvents; } } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/repositories/RevisionsEventRepository.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/repositories/RevisionsEventRepository.java index a2b6203..6f80cbc 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/repositories/RevisionsEventRepository.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/repositories/RevisionsEventRepository.java @@ -3,6 +3,7 @@ import edu.stanford.protege.webprotege.common.ProjectId; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.events.RevisionsEvent; import org.springframework.data.mongodb.repository.*; +import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -11,5 +12,6 @@ public interface RevisionsEventRepository extends MongoRepository findByProjectIdAndTimestampAfter(String projectId, long timestamp); List findByProjectIdAndWhoficEntityIriOrderByTimestampDesc(ProjectId projectId, String whoficEntityIri); - + @Transactional + void deleteByChangeRequestIdAndWhoficEntityIri(String changeRequestId, String whoficEntityIri); } diff --git a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java index f3413f9..769f8ed 100644 --- a/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java +++ b/src/main/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceImpl.java @@ -50,6 +50,7 @@ public Page fetchPaginatedProjectChanges(ProjectId projectId, Opt entityIriSubject, null, 0, + null, null ); ExampleMatcher matcher = ExampleMatcher.matching() diff --git a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetChangedEntitiesCommandHandlerIT.java b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetChangedEntitiesCommandHandlerIT.java index e9bab5b..6c8f371 100644 --- a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetChangedEntitiesCommandHandlerIT.java +++ b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetChangedEntitiesCommandHandlerIT.java @@ -1,5 +1,6 @@ package edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.handlers; +import edu.stanford.protege.webprotege.common.ChangeRequestId; import edu.stanford.protege.webprotege.common.ProjectId; import edu.stanford.protege.webprotegeeventshistory.*; import edu.stanford.protege.webprotegeeventshistory.uiHistoryConcern.dto.*; @@ -66,8 +67,8 @@ private void insertMockRevisionsEvent(ProjectId projectId, String entityIri, lon entityIri, changeType, timestamp, - new Document() - ); + new Document(), + ChangeRequestId.generate()); mongoTemplate.save(revisionsEvent); } } diff --git a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetProjectChangesForHistoryViewCommandHandlerIntegrationTest.java b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetProjectChangesForHistoryViewCommandHandlerIntegrationTest.java index 826d70a..bb9bb54 100644 --- a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetProjectChangesForHistoryViewCommandHandlerIntegrationTest.java +++ b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/GetProjectChangesForHistoryViewCommandHandlerIntegrationTest.java @@ -133,7 +133,7 @@ private OWLEntity mockOWLEntity(String iri) { private ProjectChange insertMockRevisionsEvent(ProjectId projectId, String whoficEntityIri, long timestamp) { ProjectChange projectChange = ProjectChange.get(RevisionNumber.getRevisionNumber(1), UserId.valueOf("user1"), timestamp, "Description1", 0, Page.emptyPage()); org.bson.Document projectChangeDocument = objectMapper.convertValue(projectChange, Document.class); - RevisionsEvent revisionsEvent = RevisionsEvent.create(projectId, whoficEntityIri, ChangeType.UPDATE_ENTITY, timestamp, projectChangeDocument); + RevisionsEvent revisionsEvent = RevisionsEvent.create(projectId, whoficEntityIri, ChangeType.UPDATE_ENTITY, timestamp, projectChangeDocument, ChangeRequestId.generate()); mongoTemplate.save(revisionsEvent); return projectChange; diff --git a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandlerIntegrationTest.java b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandlerIntegrationTest.java index 7100df1..eb8738b 100644 --- a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandlerIntegrationTest.java +++ b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/handlers/NewRevisionsEventHandlerIntegrationTest.java @@ -50,7 +50,7 @@ public void GIVEN_validNewLinearizationRevisionsEvent_WHEN_handleEventCalled_THE changes.add(ProjectChangeForEntity.create("whoficEntityIri1", projectChange1)); changes.add(ProjectChangeForEntity.create("whoficEntityIri2", projectChange2)); - NewRevisionsEvent newLinRevEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changes); + NewRevisionsEvent newLinRevEvent = NewRevisionsEvent.create(EventId.generate(), projectId, changes, ChangeRequestId.generate()); handler.handleEvent(newLinRevEvent); @@ -73,7 +73,7 @@ public void GIVEN_emptyChanges_WHEN_handleEventCalled_THEN_noEventsAreSavedToDat ProjectId projectId = ProjectId.generate(); Set emptyChanges = new LinkedHashSet<>(); - NewRevisionsEvent emptyEvent = NewRevisionsEvent.create(EventId.generate(), projectId, emptyChanges); + NewRevisionsEvent emptyEvent = NewRevisionsEvent.create(EventId.generate(), projectId, emptyChanges, ChangeRequestId.generate()); handler.handleEvent(emptyEvent); @@ -106,8 +106,8 @@ public void GIVEN_multipleValidEvents_WHEN_handleEventCalled_THEN_allEventsAreRe changesForSecondEvent.add(ProjectChangeForEntity.create("whoficEntityIri3", projectChange3)); - NewRevisionsEvent firstEvent = NewRevisionsEvent.create(EventId.generate(), projectId1, changesForFirstEvent); - NewRevisionsEvent secondEvent = NewRevisionsEvent.create(EventId.generate(), projectId2, changesForSecondEvent); + NewRevisionsEvent firstEvent = NewRevisionsEvent.create(EventId.generate(), projectId1, changesForFirstEvent, ChangeRequestId.generate()); + NewRevisionsEvent secondEvent = NewRevisionsEvent.create(EventId.generate(), projectId2, changesForSecondEvent, ChangeRequestId.generate()); handler.handleEvent(firstEvent); handler.handleEvent(secondEvent); diff --git a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapperTest.java b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapperTest.java index 49caf1a..c5ab4b7 100644 --- a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapperTest.java +++ b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/mappers/RevisionEventMapperTest.java @@ -39,7 +39,7 @@ public void GIVEN_validProjectIdAndChanges_WHEN_mapNewLinearizationRevisionsEven Document mockDocument = new Document(); when(objectMapper.convertValue(mockProjectChange, Document.class)).thenReturn(mockDocument); - List result = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, changes)); + List result = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, changes, ChangeRequestId.generate())); assertNotNull(result); assertEquals(2, result.size()); @@ -63,7 +63,7 @@ public void GIVEN_emptyChangesSet_WHEN_mapNewLinearizationRevisionsEventToRevisi ProjectId projectId = new ProjectId("testProjectId"); Set emptyChanges = Set.of(); - List result = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, emptyChanges)); + List result = revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, emptyChanges, ChangeRequestId.generate())); assertNotNull(result); assertTrue(result.isEmpty()); @@ -75,7 +75,7 @@ public void GIVEN_nullChangesSet_WHEN_mapNewLinearizationRevisionsEventToRevisio ProjectId projectId = new ProjectId("testProjectId"); Set nullChanges = null; - assertThrows(NullPointerException.class, () -> revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, nullChanges))); + assertThrows(NullPointerException.class, () -> revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(NewRevisionsEvent.create(EventId.generate(), projectId, nullChanges, ChangeRequestId.generate()))); verifyNoInteractions(objectMapper); } diff --git a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceTest.java b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceTest.java index 9e4a035..5608f59 100644 --- a/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceTest.java +++ b/src/test/java/edu/stanford/protege/webprotegeeventshistory/uiHistoryConcern/services/NewRevisionsEventServiceTest.java @@ -54,9 +54,9 @@ public void setUp() { @Test public void GIVEN_validNewLinearizationRevisionsEvent_WHEN_registerEventCalled_THEN_revisionsEventsSavedToRepository() { Set changes = Set.of(mock(ProjectChangeForEntity.class)); - NewRevisionsEvent event = NewRevisionsEvent.create(EventId.generate(), projectId, changes); + NewRevisionsEvent event = NewRevisionsEvent.create(EventId.generate(), projectId, changes, ChangeRequestId.generate()); - RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, "whoficEntityIri", ChangeType.UPDATE_ENTITY, 12345L, new Document()); + RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, "whoficEntityIri", ChangeType.UPDATE_ENTITY, 12345L, new Document(), ChangeRequestId.generate()); when(revisionEventMapper.mapNewRevisionsEventToRevisionsEvents(event)) .thenReturn(List.of(mockRevisionsEvent)); @@ -72,7 +72,7 @@ public void GIVEN_validProjectIdAndSubject_WHEN_fetchPaginatedProjectChangesCall IRI mockIri = IRI.create("http://example.com/entity"); when(mockEntity.getIRI()).thenReturn(mockIri); - RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, mockIri.toString(), ChangeType.UPDATE_ENTITY, 12345L, new Document()); + RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, mockIri.toString(), ChangeType.UPDATE_ENTITY, 12345L, new Document(), ChangeRequestId.generate()); PageRequest pageRequest = PageRequest.of(0, 1, Sort.by(Sort.Direction.DESC, "timestamp")); org.springframework.data.domain.Page mockPage = new PageImpl<>(List.of(mockRevisionsEvent), pageRequest, 1); @@ -94,7 +94,7 @@ public void GIVEN_validProjectIdAndSubject_WHEN_fetchPaginatedProjectChangesCall @Test public void GIVEN_nullSubject_WHEN_fetchPaginatedProjectChangesCalled_THEN_returnPaginatedProjectChanges() { - RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, null, ChangeType.CREATE_ENTITY, 12345L, new Document()); + RevisionsEvent mockRevisionsEvent = RevisionsEvent.create(projectId, null, ChangeType.CREATE_ENTITY, 12345L, new Document(), ChangeRequestId.generate()); PageRequest pageRequest = PageRequest.of(0, 1, Sort.by(Sort.Direction.DESC, "timestamp")); org.springframework.data.domain.Page mockPage = new PageImpl<>(List.of(mockRevisionsEvent), pageRequest, 1); @@ -145,9 +145,9 @@ public void GIVEN_noEntitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTi @Test public void GIVEN_entitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTimestampCalled_THEN_returnGroupedChangedEntities() { - RevisionsEvent createdEntity = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime(), new Document()); - RevisionsEvent updatedEntity = RevisionsEvent.create(projectId, "entityIRI2", ChangeType.UPDATE_ENTITY, timestamp.getTime() + 1000, new Document()); - RevisionsEvent deletedEntity = RevisionsEvent.create(projectId, "entityIRI3", ChangeType.DELETE_ENTITY, timestamp.getTime() + 2000, new Document()); + RevisionsEvent createdEntity = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime(), new Document(), ChangeRequestId.generate()); + RevisionsEvent updatedEntity = RevisionsEvent.create(projectId, "entityIRI2", ChangeType.UPDATE_ENTITY, timestamp.getTime() + 1000, new Document(), ChangeRequestId.generate()); + RevisionsEvent deletedEntity = RevisionsEvent.create(projectId, "entityIRI3", ChangeType.DELETE_ENTITY, timestamp.getTime() + 2000, new Document(), ChangeRequestId.generate()); when(repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime())).thenReturn(List.of(createdEntity, updatedEntity, deletedEntity)); @@ -167,9 +167,9 @@ public void GIVEN_entitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTime @Test public void GIVEN_multipleEntitiesChangedAfterTimestamp_WHEN_getChangedEntitiesAfterTimestampCalled_THEN_returnDeduplicatedChangedEntities() { - RevisionsEvent createdEntity1 = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime(), new Document()); - RevisionsEvent createdEntity2 = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime() + 1000, new Document()); - RevisionsEvent updatedEntity = RevisionsEvent.create(projectId, "entityIRI2", ChangeType.UPDATE_ENTITY, timestamp.getTime() + 2000, new Document()); + RevisionsEvent createdEntity1 = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime(), new Document(), ChangeRequestId.generate()); + RevisionsEvent createdEntity2 = RevisionsEvent.create(projectId, "entityIRI1", ChangeType.CREATE_ENTITY, timestamp.getTime() + 1000, new Document(), ChangeRequestId.generate()); + RevisionsEvent updatedEntity = RevisionsEvent.create(projectId, "entityIRI2", ChangeType.UPDATE_ENTITY, timestamp.getTime() + 2000, new Document(), ChangeRequestId.generate()); when(repository.findByProjectIdAndTimestampAfter(projectId.id(), timestamp.getTime())).thenReturn(List.of(createdEntity1, createdEntity2, updatedEntity)); @@ -212,8 +212,8 @@ public void GIVEN_validHistoryForEntity_WHEN_getEntityHistorySummaryCalled_THEN_ Document document1 = new Document("a", "b"); Document document2 = new Document("c", "d"); - RevisionsEvent eventCreate = RevisionsEvent.create(projectId, entityIri, ChangeType.CREATE_ENTITY, timestamp2, document2); - RevisionsEvent eventUpdate = RevisionsEvent.create(projectId, entityIri, ChangeType.UPDATE_ENTITY, timestamp1, document1); + RevisionsEvent eventCreate = RevisionsEvent.create(projectId, entityIri, ChangeType.CREATE_ENTITY, timestamp2, document2, ChangeRequestId.generate()); + RevisionsEvent eventUpdate = RevisionsEvent.create(projectId, entityIri, ChangeType.UPDATE_ENTITY, timestamp1, document1, ChangeRequestId.generate()); ProjectChange changeCreate = ProjectChange.get( RevisionNumber.getRevisionNumber(1),