Skip to content
Snippets Groups Projects
Commit 807e3f48 authored by OZGCloud's avatar OZGCloud
Browse files

Merge pull request 'OZG-5726: leave lastest upate_bescheid command for...

Merge pull request 'OZG-5726: leave lastest upate_bescheid command for send_bescheid command (send by nachricht)' (#611) from OZG-5726-historie-erweiterung into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/611


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 05e0a30c 868d9c52
Branches
Tags 2.5.2
No related merge requests found
...@@ -56,11 +56,11 @@ class BescheidHistorieProcessor implements HistorieProcessor { ...@@ -56,11 +56,11 @@ class BescheidHistorieProcessor implements HistorieProcessor {
} }
List<Command> filterBescheidRelatedCommands(List<Command> commands) { List<Command> filterBescheidRelatedCommands(List<Command> commands) {
var commandIdsToFilter = getBescheidRelatedCommandIdsToFilter(commands); var excludeCommandIds = getExcludedBescheidRelatedCommandIds(commands);
return commands.stream().filter(command -> !commandIdsToFilter.contains(command.getId())).toList(); 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 sendBescheidCommands = commands.stream().filter(this::isSendBescheidCommand).toList();
var sendBescheidCommandsRelationIds = sendBescheidCommands.stream().map(Command::getRelationId).toList(); var sendBescheidCommandsRelationIds = sendBescheidCommands.stream().map(Command::getRelationId).toList();
var orphanedUpdateBescheidCommands = commands.stream().filter(IS_UPDATE_BESCHEID_COMMAND) var orphanedUpdateBescheidCommands = commands.stream().filter(IS_UPDATE_BESCHEID_COMMAND)
...@@ -80,7 +80,7 @@ class BescheidHistorieProcessor implements HistorieProcessor { ...@@ -80,7 +80,7 @@ class BescheidHistorieProcessor implements HistorieProcessor {
if (isManualSent(getVorgangAttachedItem(sendBescheidCommand.getRelationId()).getItem())) { if (isManualSent(getVorgangAttachedItem(sendBescheidCommand.getRelationId()).getItem())) {
return Stream.concat(Stream.of(sendBescheidCommand.getId()), filterLatestByCreatedAt(relatedUpdateBescheidCommands)).toList(); return Stream.concat(Stream.of(sendBescheidCommand.getId()), filterLatestByCreatedAt(relatedUpdateBescheidCommands)).toList();
} else { } else {
return relatedUpdateBescheidCommands.stream().map(Command::getId).toList(); return filterLatestByCreatedAt(relatedUpdateBescheidCommands).toList();
} }
} }
......
...@@ -131,14 +131,14 @@ class BescheidHistorieProcessorTest { ...@@ -131,14 +131,14 @@ class BescheidHistorieProcessorTest {
@BeforeEach @BeforeEach
void mock() { void mock() {
doReturn(Collections.singletonList(commandToFilter.getId())).when(processor).getBescheidRelatedCommandIdsToFilter(any()); doReturn(Collections.singletonList(commandToFilter.getId())).when(processor).getExcludedBescheidRelatedCommandIds(any());
} }
@Test @Test
void shouldGetBescheidRelatedCommandIdsToFilter() { void shouldGetBescheidRelatedCommandIdsToFilter() {
processor.filterBescheidRelatedCommands(commands); processor.filterBescheidRelatedCommands(commands);
verify(processor).getBescheidRelatedCommandIdsToFilter(commands); verify(processor).getExcludedBescheidRelatedCommandIds(commands);
} }
@Test @Test
...@@ -177,14 +177,14 @@ class BescheidHistorieProcessorTest { ...@@ -177,14 +177,14 @@ class BescheidHistorieProcessorTest {
@Test @Test
void shouldGetCommandIdsToFilter() { void shouldGetCommandIdsToFilter() {
processor.getBescheidRelatedCommandIdsToFilter(commands); processor.getExcludedBescheidRelatedCommandIds(commands);
verify(processor).getCommandIdsToFilter(sendBescheidCommand, commands); verify(processor).getCommandIdsToFilter(sendBescheidCommand, commands);
} }
@Test @Test
void shouldReturnIdsToFilter() { void shouldReturnIdsToFilter() {
var commandIds = processor.getBescheidRelatedCommandIdsToFilter(commands); var commandIds = processor.getExcludedBescheidRelatedCommandIds(commands);
assertThat(commandIds).containsExactlyInAnyOrder(updateBescheidCommand.getId(), updateBescheidCommandOfBescheidNotSent.getId()); assertThat(commandIds).containsExactlyInAnyOrder(updateBescheidCommand.getId(), updateBescheidCommandOfBescheidNotSent.getId());
} }
...@@ -279,7 +279,7 @@ class BescheidHistorieProcessorTest { ...@@ -279,7 +279,7 @@ class BescheidHistorieProcessorTest {
void shouldReturnRelatedCommandIds() { void shouldReturnRelatedCommandIds() {
var ids = processor.getCommandIdsToFilter(sendBescheidCommand, relatedUpdateBescheidCommands); var ids = processor.getCommandIdsToFilter(sendBescheidCommand, relatedUpdateBescheidCommands);
assertThat(ids).containsExactly(relatedUpdateBescheidCommand.getId(), relatedLatestUpdateBescheidCommand.getId()); assertThat(ids).containsExactly(relatedUpdateBescheidCommand.getId());
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment