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

OZG-4189 OZG-4549 use spring application name; update property

parent ceb67606
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.ozgcloud.alfa.AlfaSpringProperties;
import de.ozgcloud.alfa.common.user.CurrentUserService;
import de.ozgcloud.alfa.common.user.UserRole;
import de.ozgcloud.alfa.vorgang.Vorgang.VorgangStatus;
......@@ -17,7 +18,7 @@ class StatisticService {
// TODO sebo: dieser Code wird später gelöscht
static final String COUNT_WIEDERVORLAGE_NEXT_FRIST_KEY = "countWiedervorlage";
static final String COUNT_WIEDERVORLAGE_NEXT_FRIST = COUNT_WIEDERVORLAGE_NEXT_FRIST_KEY + ":ClientAttribute.Goofy.nextWiedervorlageFrist";
static final String COUNT_WIEDERVORLAGE_NEXT_FRIST_TEMPLATE = COUNT_WIEDERVORLAGE_NEXT_FRIST_KEY + ":ClientAttribute.%s.nextWiedervorlageFrist";
// END: code löschen
static final List<VorgangStatus> VORGAENGE_STATUS_COUNT_VERWALTUNG_USER = List.of(VorgangStatus.NEU, VorgangStatus.ANGENOMMEN,
......@@ -31,6 +32,9 @@ class StatisticService {
@Autowired
private CurrentUserService currentUserService;
@Autowired
private AlfaSpringProperties alfaSpringProperties;
public Statistic getVorgaengeStatistic() {
var response = remoteService.getVorgaengeStatistics(List.of(VorgangStatus.ZU_LOESCHEN));
return buildGetVorgaengeStatisticResult(response);
......@@ -81,7 +85,7 @@ class StatisticService {
}
List<String> createCountByPathList() {
return List.of(COUNT_WIEDERVORLAGE_NEXT_FRIST);
return List.of(String.format(COUNT_WIEDERVORLAGE_NEXT_FRIST_TEMPLATE, alfaSpringProperties.getApplicationName()));
}
Statistic buildStatistic(CountVorgangResponse response) {
......
......@@ -3,6 +3,7 @@ package de.ozgcloud.alfa.statistic;
import static de.ozgcloud.alfa.statistic.StatisticRemoteService.*;
import static de.ozgcloud.alfa.statistic.StatisticService.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.Collections;
......@@ -18,6 +19,9 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import com.thedeanda.lorem.LoremIpsum;
import de.ozgcloud.alfa.AlfaSpringProperties;
import de.ozgcloud.alfa.common.user.CurrentUserService;
import de.ozgcloud.alfa.common.user.UserRole;
import de.ozgcloud.alfa.vorgang.Vorgang.VorgangStatus;
......@@ -31,6 +35,8 @@ class StatisticServiceTest {
private StatisticRemoteService remoteService;
@Mock
private CurrentUserService currentUserService;
@Mock
private AlfaSpringProperties alfaSpringProperties;
@Nested
class TestBuildGetVorgaengeStatisticResult {
......@@ -224,25 +230,28 @@ class StatisticServiceTest {
}
// TODO sebo: später löschen
@DisplayName("Get statistic")
@DisplayName("Count vorgang")
@Nested
class TestGetStatistic {
class TestCountVorgang {
private static final int WIEDERVORLAGE_COUNT = 8;
private CountVorgangResponse response = CountVorgangResponseTestFactory.createBuilder()
.pathCountResult(Map.of(StatisticService.COUNT_WIEDERVORLAGE_NEXT_FRIST_KEY, WIEDERVORLAGE_COUNT)).build();
private final String applicationName = LoremIpsum.getInstance().getFirstName();
@Test
void shouldCallRemoteService() {
when(alfaSpringProperties.getApplicationName()).thenReturn(applicationName);
when(remoteService.countVorgang(any())).thenReturn(response);
service.countVorgang();
verify(remoteService).countVorgang(List.of(StatisticService.COUNT_WIEDERVORLAGE_NEXT_FRIST));
verify(remoteService).countVorgang(List.of(String.format(StatisticService.COUNT_WIEDERVORLAGE_NEXT_FRIST_TEMPLATE, applicationName)));
}
@Test
void shouldBuildStatistic() {
when(alfaSpringProperties.getApplicationName()).thenReturn(applicationName);
when(remoteService.countVorgang(any())).thenReturn(response);
service.countVorgang();
......
......@@ -23,7 +23,7 @@ spring:
pathmatch:
matching-strategy: ant-path-matcher
application:
name: Goofy
name: Alfa
jackson:
deserialization:
'ADJUST_DATES_TO_CONTEXT_TIME_ZONE': false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment