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

Merge pull request 'OZG-4994-OZG-5061-add-unread-messages-to-statistics'...

Merge pull request 'OZG-4994-OZG-5061-add-unread-messages-to-statistics' (#422) from OZG-4994-OZG-5061-add-unread-messages-to-statistics into OZG-4994-ansicht-vorgaenge-mit-ungelesene-nachrichten

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/alfa/pulls/422
parents 6f7d4766 8780fb33
Branches
No related tags found
No related merge requests found
...@@ -12,4 +12,5 @@ public class Statistic { ...@@ -12,4 +12,5 @@ public class Statistic {
private ByStatus byStatus; private ByStatus byStatus;
private int wiedervorlagen; private int wiedervorlagen;
private boolean existsWiedervorlageOverdue; private boolean existsWiedervorlageOverdue;
private int ungeleseneNachrichten;
} }
...@@ -25,9 +25,11 @@ class StatisticRemoteService { ...@@ -25,9 +25,11 @@ class StatisticRemoteService {
static final String COUNT_VORGANG_STATUS_RESULT_NAME_FORMAT = "countVorgangStatus_%s"; static final String COUNT_VORGANG_STATUS_RESULT_NAME_FORMAT = "countVorgangStatus_%s";
static final String COUNT_WIEDERVORLAGE_NEXT_FRIST_RESULT_NAME = "countWiedervorlage"; static final String COUNT_WIEDERVORLAGE_NEXT_FRIST_RESULT_NAME = "countWiedervorlage";
static final String EXISTS_WIEDERVORLAGE_OVERDUE_RESULT_NAME = "existsWiedervorlageOverdue"; static final String EXISTS_WIEDERVORLAGE_OVERDUE_RESULT_NAME = "existsWiedervorlageOverdue";
static final String COUNT_VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_RESULT_NAME = "countVorgaengeWithUngeleseneNachrichten";
static final String STATUS_PATH = "Vorgang.status"; static final String STATUS_PATH = "Vorgang.status";
static final String WIEDERVORLAGE_NEXT_FRIST_PATH_TEMPLATE = "ClientAttribute.%s.nextWiedervorlageFrist"; static final String WIEDERVORLAGE_NEXT_FRIST_PATH_TEMPLATE = "ClientAttribute.%s.nextWiedervorlageFrist";
static final String VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_PATH = "ClientAttribute.OzgCloud_NachrichtenManager.hasNewPostfachNachricht";
static final String OPERAND_TODAY_DATE = "today()"; static final String OPERAND_TODAY_DATE = "today()";
...@@ -43,6 +45,7 @@ class StatisticRemoteService { ...@@ -43,6 +45,7 @@ class StatisticRemoteService {
.addAllQuery(buildCountByStatusQueries(countByVorgangStatus)) .addAllQuery(buildCountByStatusQueries(countByVorgangStatus))
.addQuery(buildCountWiedervorlageNextFristQuery()) .addQuery(buildCountWiedervorlageNextFristQuery())
.addQuery(buildExistsWiedervorlageOverdueQuery()) .addQuery(buildExistsWiedervorlageOverdueQuery())
.addQuery(buildCountVorgaengeWithUngeleseneNachrichtenQuery())
.build(); .build();
var grpcResponse = statisticServiceStub.getVorgangStatistic(grpcRequest); var grpcResponse = statisticServiceStub.getVorgangStatistic(grpcRequest);
...@@ -93,4 +96,14 @@ class StatisticRemoteService { ...@@ -93,4 +96,14 @@ class StatisticRemoteService {
.map(mapper::toResult) .map(mapper::toResult)
.collect(Collectors.toMap(StatisticResult::getName, Function.identity())); .collect(Collectors.toMap(StatisticResult::getName, Function.identity()));
} }
public GrpcVorgangStatisticQuery buildCountVorgaengeWithUngeleseneNachrichtenQuery() {
return GrpcVorgangStatisticQuery.newBuilder()
.setResultName(COUNT_VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_RESULT_NAME)
.setPath(VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_PATH)
.setGroupMethod(GroupMethod.COUNT)
.setOperator(Operator.EQUAL)
.setOperandBoolValue(true)
.build();
}
} }
\ No newline at end of file
...@@ -48,6 +48,7 @@ class StatisticService { ...@@ -48,6 +48,7 @@ class StatisticService {
return Statistic.builder() return Statistic.builder()
.existsWiedervorlageOverdue(getBooleanResult(response, StatisticRemoteService.EXISTS_WIEDERVORLAGE_OVERDUE_RESULT_NAME)) .existsWiedervorlageOverdue(getBooleanResult(response, StatisticRemoteService.EXISTS_WIEDERVORLAGE_OVERDUE_RESULT_NAME))
.wiedervorlagen(getIntResult(response, StatisticRemoteService.COUNT_WIEDERVORLAGE_NEXT_FRIST_RESULT_NAME)) .wiedervorlagen(getIntResult(response, StatisticRemoteService.COUNT_WIEDERVORLAGE_NEXT_FRIST_RESULT_NAME))
.ungeleseneNachrichten(getIntResult(response, StatisticRemoteService.COUNT_VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_RESULT_NAME))
.byStatus(ByStatus.builder() .byStatus(ByStatus.builder()
.neu(getIntResult(response, remoteService.buildCountByStatusResultName(VorgangStatus.NEU))) .neu(getIntResult(response, remoteService.buildCountByStatusResultName(VorgangStatus.NEU)))
.abgeschlossen(getIntResult(response, remoteService.buildCountByStatusResultName(VorgangStatus.ABGESCHLOSSEN))) .abgeschlossen(getIntResult(response, remoteService.buildCountByStatusResultName(VorgangStatus.ABGESCHLOSSEN)))
......
package de.ozgcloud.alfa.statistic; package de.ozgcloud.alfa.statistic;
import com.thedeanda.lorem.LoremIpsum;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery;
public class GrpcVorgangStatisticQueryTestFactory { public class GrpcVorgangStatisticQueryTestFactory {
public static final String RESULT_NAME = LoremIpsum.getInstance().getWords(1);
public static GrpcVorgangStatisticQuery create() { public static GrpcVorgangStatisticQuery create() {
return createBuilder().build(); return createBuilder().build();
} }
public static GrpcVorgangStatisticQuery.Builder createBuilder() { public static GrpcVorgangStatisticQuery.Builder createBuilder() {
return GrpcVorgangStatisticQuery.newBuilder(); return GrpcVorgangStatisticQuery.newBuilder()
.setResultName(RESULT_NAME);
} }
} }
...@@ -15,6 +15,8 @@ import org.junit.jupiter.api.Test; ...@@ -15,6 +15,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.EnumSource.Mode; import org.junit.jupiter.params.provider.EnumSource.Mode;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Spy; import org.mockito.Spy;
...@@ -26,6 +28,7 @@ import de.ozgcloud.alfa.vorgang.Vorgang.VorgangStatus; ...@@ -26,6 +28,7 @@ import de.ozgcloud.alfa.vorgang.Vorgang.VorgangStatus;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.GroupMethod; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.GroupMethod;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.Operator; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticQuery.Operator;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticRequest;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResponse; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResponse;
import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResult; import de.ozgcloud.vorgang.statistic.GrpcVorgangStatisticResult;
import de.ozgcloud.vorgang.statistic.StatisticServiceGrpc.StatisticServiceBlockingStub; import de.ozgcloud.vorgang.statistic.StatisticServiceGrpc.StatisticServiceBlockingStub;
...@@ -190,12 +193,20 @@ class StatisticRemoteServiceTest { ...@@ -190,12 +193,20 @@ class StatisticRemoteServiceTest {
class TestGetVorgaengeStatistics { class TestGetVorgaengeStatistics {
private final GrpcVorgangStatisticResponse response = GrpcVorgangStatisticResponseTestFactory.create(); private final GrpcVorgangStatisticResponse response = GrpcVorgangStatisticResponseTestFactory.create();
private final GrpcVorgangStatisticQuery countVorgaengeWithUngeleseneNachrichtenQuery = GrpcVorgangStatisticQueryTestFactory.createBuilder()
.setResultName("ungelesene nachrichten").build();
private final GrpcVorgangStatisticQuery existsWiedervorlageOverdueQuery = GrpcVorgangStatisticQueryTestFactory.createBuilder()
.setResultName("exists overdue").build();
@Captor
private ArgumentCaptor<GrpcVorgangStatisticRequest> grpcRequestCaptor;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach() {
when(serviceStub.getVorgangStatistic(any())).thenReturn(response); when(serviceStub.getVorgangStatistic(any())).thenReturn(response);
doReturn(GrpcVorgangStatisticQueryTestFactory.create()).when(service).buildExistsWiedervorlageOverdueQuery(); doReturn(existsWiedervorlageOverdueQuery).when(service).buildExistsWiedervorlageOverdueQuery();
doReturn(countVorgaengeWithUngeleseneNachrichtenQuery).when(service).buildCountVorgaengeWithUngeleseneNachrichtenQuery();
} }
@Test @Test
...@@ -232,6 +243,21 @@ class StatisticRemoteServiceTest { ...@@ -232,6 +243,21 @@ class StatisticRemoteServiceTest {
verify(service).buildStatisticResult(response); verify(service).buildStatisticResult(response);
} }
@Test
void shouldCallBuildCountVorgaengeWithUngeleseneNachrichtenQuery() {
service.getVorgaengeStatistics(STATUSES_TO_COUNT);
verify(service).buildCountVorgaengeWithUngeleseneNachrichtenQuery();
}
@Test
void shouldAddCountVorgaengeWithUngeleseneNachrichtenQuery() {
service.getVorgaengeStatistics(STATUSES_TO_COUNT);
verify(serviceStub).getVorgangStatistic(grpcRequestCaptor.capture());
assertThat(grpcRequestCaptor.getValue().getQueryList()).contains(countVorgaengeWithUngeleseneNachrichtenQuery);
}
} }
@Nested @Nested
...@@ -270,4 +296,47 @@ class StatisticRemoteServiceTest { ...@@ -270,4 +296,47 @@ class StatisticRemoteServiceTest {
.hasEntrySatisfying(RESULT_NAME, statisticResult -> assertThat(statisticResult.getIntValue()).isEqualTo(RESULT_INT)); .hasEntrySatisfying(RESULT_NAME, statisticResult -> assertThat(statisticResult.getIntValue()).isEqualTo(RESULT_INT));
} }
} }
@Nested
class TestBuildCountVorgaengeWithUngeleseneNachrichtenQuery {
@Test
void shouldHaveResultName() {
var query = callService();
assertThat(query.getResultName()).isEqualTo(COUNT_VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_RESULT_NAME);
}
@Test
void shouldHavePath() {
var query = callService();
assertThat(query.getPath()).isEqualTo(VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_PATH);
}
@Test
void shouldHaveGroupingMethod() {
var query = callService();
assertThat(query.getGroupMethod()).isEqualTo(GroupMethod.COUNT);
}
@Test
void shouldHaveOperator() {
var query = callService();
assertThat(query.getOperator()).isEqualTo(Operator.EQUAL);
}
@Test
void shouldHaveOperandValue() {
var query = callService();
assertThat(query.getOperandBoolValue()).isTrue();
}
private GrpcVorgangStatisticQuery callService() {
return service.buildCountVorgaengeWithUngeleseneNachrichtenQuery();
}
}
} }
\ No newline at end of file
...@@ -138,6 +138,14 @@ class StatisticServiceTest { ...@@ -138,6 +138,14 @@ class StatisticServiceTest {
assertThat(statistic.getByStatus().getNeu()).isZero(); assertThat(statistic.getByStatus().getNeu()).isZero();
} }
@Test
void shouldContainUngeleseneNachrichten() {
var statistic = service.buildGetVorgaengeStatisticResult(
Map.of(COUNT_VORGAENGE_WITH_UNGELESENE_NACHRICHTEN_RESULT_NAME, StatisticResultTestFactory.create()));
assertThat(statistic.getUngeleseneNachrichten()).isEqualTo(StatisticResultTestFactory.INT_VALUE);
}
} }
@Nested @Nested
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment