diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessor.java b/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessor.java index 8a7a0c580ab7f9e4aa75e5cc9476dddbe0176e00..3a134ac79f67c11e6168fe0116bcebbbfe94b24f 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessor.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessor.java @@ -56,11 +56,11 @@ class BescheidHistorieProcessor implements HistorieProcessor { } List<Command> filterBescheidRelatedCommands(List<Command> commands) { - var commandIdsToFilter = getBescheidRelatedCommandIdsToFilter(commands); - return commands.stream().filter(command -> !commandIdsToFilter.contains(command.getId())).toList(); + var excludeCommandIds = getExcludedBescheidRelatedCommandIds(commands); + return commands.stream().filter(command -> !excludeCommandIds.contains(command.getId())).toList(); } - List<String> getBescheidRelatedCommandIdsToFilter(List<Command> commands) { + List<String> getExcludedBescheidRelatedCommandIds(List<Command> commands) { var sendBescheidCommands = commands.stream().filter(this::isSendBescheidCommand).toList(); var sendBescheidCommandsRelationIds = sendBescheidCommands.stream().map(Command::getRelationId).toList(); var orphanedUpdateBescheidCommands = commands.stream().filter(IS_UPDATE_BESCHEID_COMMAND) @@ -80,7 +80,7 @@ class BescheidHistorieProcessor implements HistorieProcessor { if (isManualSent(getVorgangAttachedItem(sendBescheidCommand.getRelationId()).getItem())) { return Stream.concat(Stream.of(sendBescheidCommand.getId()), filterLatestByCreatedAt(relatedUpdateBescheidCommands)).toList(); } else { - return relatedUpdateBescheidCommands.stream().map(Command::getId).toList(); + return filterLatestByCreatedAt(relatedUpdateBescheidCommands).toList(); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessorTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessorTest.java index 8e57e2cf77ad8ce2eacf789e1d113c6755b8401d..ac60d058d4b2b3a315ac2312cae6375a160275d6 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessorTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/bescheid/BescheidHistorieProcessorTest.java @@ -131,14 +131,14 @@ class BescheidHistorieProcessorTest { @BeforeEach void mock() { - doReturn(Collections.singletonList(commandToFilter.getId())).when(processor).getBescheidRelatedCommandIdsToFilter(any()); + doReturn(Collections.singletonList(commandToFilter.getId())).when(processor).getExcludedBescheidRelatedCommandIds(any()); } @Test void shouldGetBescheidRelatedCommandIdsToFilter() { processor.filterBescheidRelatedCommands(commands); - verify(processor).getBescheidRelatedCommandIdsToFilter(commands); + verify(processor).getExcludedBescheidRelatedCommandIds(commands); } @Test @@ -177,14 +177,14 @@ class BescheidHistorieProcessorTest { @Test void shouldGetCommandIdsToFilter() { - processor.getBescheidRelatedCommandIdsToFilter(commands); + processor.getExcludedBescheidRelatedCommandIds(commands); verify(processor).getCommandIdsToFilter(sendBescheidCommand, commands); } @Test void shouldReturnIdsToFilter() { - var commandIds = processor.getBescheidRelatedCommandIdsToFilter(commands); + var commandIds = processor.getExcludedBescheidRelatedCommandIds(commands); assertThat(commandIds).containsExactlyInAnyOrder(updateBescheidCommand.getId(), updateBescheidCommandOfBescheidNotSent.getId()); } @@ -279,7 +279,7 @@ class BescheidHistorieProcessorTest { void shouldReturnRelatedCommandIds() { var ids = processor.getCommandIdsToFilter(sendBescheidCommand, relatedUpdateBescheidCommands); - assertThat(ids).containsExactly(relatedUpdateBescheidCommand.getId(), relatedLatestUpdateBescheidCommand.getId()); + assertThat(ids).containsExactly(relatedUpdateBescheidCommand.getId()); } }