diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/statistic/StatisticRemoteService.java b/alfa-service/src/main/java/de/ozgcloud/alfa/statistic/StatisticRemoteService.java index 149ade586adf5b4bd3facf9fe93546b5c213beaf..95b0494fd763777b1ddbc2534bf4b390de4ff83a 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/statistic/StatisticRemoteService.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/statistic/StatisticRemoteService.java @@ -45,6 +45,7 @@ class StatisticRemoteService { .addAllQuery(buildCountByStatusQueries(countByVorgangStatus)) .addQuery(buildCountWiedervorlageNextFristQuery()) .addQuery(buildExistsWiedervorlageOverdueQuery()) + .addQuery(buildCountVorgaengeWithUnreadMessagesQuery()) .build(); var grpcResponse = statisticServiceStub.getVorgangStatistic(grpcRequest); diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/GrpcVorgangStatisticQueryTestFactory.java b/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/GrpcVorgangStatisticQueryTestFactory.java index 0d26d330dc055948cec844b3cfd851f4adf72fd5..517f2f4495241c63259375ad45e7e6389b120f67 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/GrpcVorgangStatisticQueryTestFactory.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/GrpcVorgangStatisticQueryTestFactory.java @@ -1,14 +1,19 @@ package de.ozgcloud.alfa.statistic; +import com.thedeanda.lorem.LoremIpsum; + import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery; public class GrpcVorgangStatisticQueryTestFactory { + public static final String RESULT_NAME = LoremIpsum.getInstance().getWords(1); + public static GrpcVorgangStatisticQuery create() { return createBuilder().build(); } public static GrpcVorgangStatisticQuery.Builder createBuilder() { - return GrpcVorgangStatisticQuery.newBuilder(); + return GrpcVorgangStatisticQuery.newBuilder() + .setResultName(RESULT_NAME); } } diff --git a/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/StatisticRemoteServiceTest.java b/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/StatisticRemoteServiceTest.java index d105d3284071fb74a01b16a948d7e3f4ddcc498b..d65fb73e493d264087417eaec95a7466fb89b160 100644 --- a/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/StatisticRemoteServiceTest.java +++ b/alfa-service/src/test/java/de/ozgcloud/alfa/statistic/StatisticRemoteServiceTest.java @@ -15,6 +15,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.EnumSource.Mode; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; @@ -26,6 +28,7 @@ import de.ozgcloud.alfa.vorgang.Vorgang.VorgangStatus; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.GroupMethod; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.Operator; +import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticRequest; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResponse; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResult; import de.ozgcloud.vorgang.statistic.StatisticServiceGrpc.StatisticServiceBlockingStub; @@ -190,12 +193,20 @@ class StatisticRemoteServiceTest { class TestGetVorgaengeStatistics { private final GrpcVorgangStatisticResponse response = GrpcVorgangStatisticResponseTestFactory.create(); + private final GrpcVorgangStatisticQuery countVorgaengeWithUnreadMessagesQuery = GrpcVorgangStatisticQueryTestFactory.createBuilder() + .setResultName("unread messages").build(); + private final GrpcVorgangStatisticQuery existsWiedervorlageOverdueQuery = GrpcVorgangStatisticQueryTestFactory.createBuilder() + .setResultName("exists overdue").build(); + + @Captor + private ArgumentCaptor<GrpcVorgangStatisticRequest> grpcRequestCaptor; @BeforeEach void beforeEach() { when(serviceStub.getVorgangStatistic(any())).thenReturn(response); - doReturn(GrpcVorgangStatisticQueryTestFactory.create()).when(service).buildExistsWiedervorlageOverdueQuery(); + doReturn(existsWiedervorlageOverdueQuery).when(service).buildExistsWiedervorlageOverdueQuery(); + doReturn(countVorgaengeWithUnreadMessagesQuery).when(service).buildCountVorgaengeWithUnreadMessagesQuery(); } @Test @@ -232,6 +243,21 @@ class StatisticRemoteServiceTest { verify(service).buildStatisticResult(response); } + + @Test + void shouldCallBuildCountVorgaengeWithUnreadMessagesQuery() { + service.getVorgaengeStatistics(STATUSES_TO_COUNT); + + verify(service).buildCountVorgaengeWithUnreadMessagesQuery(); + } + + @Test + void shouldAddCountVorgaengeWithUnreadMessagesQuery() { + service.getVorgaengeStatistics(STATUSES_TO_COUNT); + + verify(serviceStub).getVorgangStatistic(grpcRequestCaptor.capture()); + assertThat(grpcRequestCaptor.getValue().getQueryList()).contains(countVorgaengeWithUnreadMessagesQuery); + } } @Nested