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

Merge pull request 'OZG-5697 Feature Toggle KielHackathon-Strecke' (#365) from...

Merge pull request 'OZG-5697 Feature Toggle KielHackathon-Strecke' (#365) from OZG-5697-Feature-Toggle-KielHackathon-Strecke into master

Reviewed-on: https://git.ozg-sh.de/ozgcloud-app/vorgang-manager/pulls/365


Reviewed-by: default avatarOZGCloud <ozgcloud@mgm-tp.com>
parents 6457d049 3e0fe39c
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,6 @@ import de.ozgcloud.bescheid.attacheditem.AttachedItemService; ...@@ -41,7 +41,6 @@ import de.ozgcloud.bescheid.attacheditem.AttachedItemService;
import de.ozgcloud.bescheid.binaryfile.BinaryFileService; import de.ozgcloud.bescheid.binaryfile.BinaryFileService;
import de.ozgcloud.bescheid.common.callcontext.CurrentUserService; import de.ozgcloud.bescheid.common.callcontext.CurrentUserService;
import de.ozgcloud.bescheid.nachricht.NachrichtService; import de.ozgcloud.bescheid.nachricht.NachrichtService;
import de.ozgcloud.bescheid.smartdocuments.SmartDocumentsProperties;
import de.ozgcloud.bescheid.vorgang.VorgangId; import de.ozgcloud.bescheid.vorgang.VorgangId;
import de.ozgcloud.command.Command; import de.ozgcloud.command.Command;
import de.ozgcloud.command.CommandCreatedEvent; import de.ozgcloud.command.CommandCreatedEvent;
...@@ -95,7 +94,7 @@ class BescheidEventListener { ...@@ -95,7 +94,7 @@ class BescheidEventListener {
private final ApplicationEventPublisher eventPublisher; private final ApplicationEventPublisher eventPublisher;
private final CurrentUserService userService; private final CurrentUserService userService;
private final Optional<SmartDocumentsProperties> smartDocumentsProperties; private final BescheidFeatureProperties bescheidFeatureProperties;
@EventListener(condition = IS_CREATE_BESCHEID) @EventListener(condition = IS_CREATE_BESCHEID)
public void onCreateBescheidCommand(CommandCreatedEvent event) { public void onCreateBescheidCommand(CommandCreatedEvent event) {
...@@ -103,7 +102,7 @@ class BescheidEventListener { ...@@ -103,7 +102,7 @@ class BescheidEventListener {
} }
void doCreateBescheid(Command command) { void doCreateBescheid(Command command) {
if (isKielEnvironment()) { if (bescheidFeatureProperties.isKielHackathonRoute()) {
var bescheid = doCreateBescheidBiz(command); var bescheid = doCreateBescheidBiz(command);
nachrichtService.createNachrichtDraft(bescheid); nachrichtService.createNachrichtDraft(bescheid);
eventPublisher.publishEvent(new BescheidCreatedEvent(command)); eventPublisher.publishEvent(new BescheidCreatedEvent(command));
...@@ -113,11 +112,6 @@ class BescheidEventListener { ...@@ -113,11 +112,6 @@ class BescheidEventListener {
eventPublisher.publishEvent(new BescheidCreatedEvent(command, createdItemId)); eventPublisher.publishEvent(new BescheidCreatedEvent(command, createdItemId));
} }
boolean isKielEnvironment() {
Predicate<SmartDocumentsProperties> configuredForKiel = properties -> TEMPLATE_GROUP_KIEL.equals(properties.getTemplateGroup());
return smartDocumentsProperties.filter(configuredForKiel).isPresent();
}
@EventListener(condition = IS_DELETE_BESCHEID) @EventListener(condition = IS_DELETE_BESCHEID)
public void onDeleteBescheid(CommandCreatedEvent event) { public void onDeleteBescheid(CommandCreatedEvent event) {
runWithSecurityContext(event.getSource(), this::doDeleteBescheid); runWithSecurityContext(event.getSource(), this::doDeleteBescheid);
......
...@@ -27,11 +27,15 @@ import org.springframework.boot.context.properties.ConfigurationProperties; ...@@ -27,11 +27,15 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
@Configuration @Configuration
@ConfigurationProperties(prefix = "ozgcloud.feature.bescheid") @ConfigurationProperties(prefix = "ozgcloud.feature.bescheid")
@Getter @Getter
@Setter
public class BescheidFeatureProperties { public class BescheidFeatureProperties {
private boolean storeAsDocument = false; private boolean storeAsDocument = false;
private boolean kielHackathonRoute = false;
} }
...@@ -26,6 +26,8 @@ class BescheidEventListenerITCase { ...@@ -26,6 +26,8 @@ class BescheidEventListenerITCase {
@Autowired @Autowired
private ApplicationEventPublisher publisher; private ApplicationEventPublisher publisher;
@Autowired
private BescheidFeatureProperties bescheidFeatureProperties;
@MockBean @MockBean
private BescheidService service; private BescheidService service;
...@@ -49,7 +51,12 @@ class BescheidEventListenerITCase { ...@@ -49,7 +51,12 @@ class BescheidEventListenerITCase {
@Nested @Nested
class TestCreateBescheid { class TestCreateBescheid {
private Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.CREATE_BESCHEID_ORDER).build(); private final Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.CREATE_BESCHEID_ORDER).build();
@BeforeEach
void init() {
bescheidFeatureProperties.setKielHackathonRoute(true);
}
@Test @Test
void shouldCallService() { void shouldCallService() {
...@@ -69,7 +76,7 @@ class BescheidEventListenerITCase { ...@@ -69,7 +76,7 @@ class BescheidEventListenerITCase {
@Nested @Nested
class TestDeleteBescheid { class TestDeleteBescheid {
private Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.DELETE_BESCHEID_ORDER).build(); private final Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.DELETE_BESCHEID_ORDER).build();
@Test @Test
void shouldCallService() { void shouldCallService() {
...@@ -89,7 +96,7 @@ class BescheidEventListenerITCase { ...@@ -89,7 +96,7 @@ class BescheidEventListenerITCase {
@Nested @Nested
class TestUpdateBescheid { class TestUpdateBescheid {
private Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.UPDATE_BESCHEID_ORDER).build(); private final Command command = CommandTestFactory.createBuilder().order(BescheidEventListener.UPDATE_BESCHEID_ORDER).build();
@Test @Test
void shouldCallService() { void shouldCallService() {
......
...@@ -7,7 +7,6 @@ import static org.mockito.ArgumentMatchers.*; ...@@ -7,7 +7,6 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
...@@ -22,7 +21,6 @@ import org.mockito.Mock; ...@@ -22,7 +21,6 @@ import org.mockito.Mock;
import org.mockito.Spy; import org.mockito.Spy;
import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.ApplicationEventPublisher;
import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContext;
import org.springframework.test.util.ReflectionTestUtils;
import de.ozgcloud.bescheid.attacheditem.AttachedItem; import de.ozgcloud.bescheid.attacheditem.AttachedItem;
import de.ozgcloud.bescheid.attacheditem.AttachedItemService; import de.ozgcloud.bescheid.attacheditem.AttachedItemService;
...@@ -32,7 +30,6 @@ import de.ozgcloud.bescheid.common.callcontext.CurrentUserService; ...@@ -32,7 +30,6 @@ import de.ozgcloud.bescheid.common.callcontext.CurrentUserService;
import de.ozgcloud.bescheid.common.callcontext.UserProfile; import de.ozgcloud.bescheid.common.callcontext.UserProfile;
import de.ozgcloud.bescheid.common.callcontext.UserProfileTestFactory; import de.ozgcloud.bescheid.common.callcontext.UserProfileTestFactory;
import de.ozgcloud.bescheid.nachricht.NachrichtService; import de.ozgcloud.bescheid.nachricht.NachrichtService;
import de.ozgcloud.bescheid.smartdocuments.SmartDocumentsProperties;
import de.ozgcloud.command.Command; import de.ozgcloud.command.Command;
import de.ozgcloud.command.CommandCreatedEventTestFactory; import de.ozgcloud.command.CommandCreatedEventTestFactory;
import de.ozgcloud.command.CommandFailedEvent; import de.ozgcloud.command.CommandFailedEvent;
...@@ -103,7 +100,7 @@ class BescheidEventListenerTest { ...@@ -103,7 +100,7 @@ class BescheidEventListenerTest {
@BeforeEach @BeforeEach
void init() { void init() {
doReturn(true).when(listener).isKielEnvironment(); when(featureProperties.isKielHackathonRoute()).thenReturn(true);
} }
@Test @Test
...@@ -136,11 +133,6 @@ class BescheidEventListenerTest { ...@@ -136,11 +133,6 @@ class BescheidEventListenerTest {
@Nested @Nested
class TestNotKielConfigured { class TestNotKielConfigured {
@BeforeEach
void init() {
doReturn(false).when(listener).isKielEnvironment();
}
@Test @Test
void shouldCallCreateBescheidDraft() { void shouldCallCreateBescheidDraft() {
listener.doCreateBescheid(COMMAND); listener.doCreateBescheid(COMMAND);
...@@ -176,42 +168,6 @@ class BescheidEventListenerTest { ...@@ -176,42 +168,6 @@ class BescheidEventListenerTest {
} }
@Nested
class TestIsKielEnvironment {
@Mock
private SmartDocumentsProperties smartDocumentsProperties;
@Test
void shouldReturnTrueIfKiel() {
when(smartDocumentsProperties.getTemplateGroup()).thenReturn("Kiel");
ReflectionTestUtils.setField(listener, "smartDocumentsProperties", Optional.of(smartDocumentsProperties));
var result = listener.isKielEnvironment();
assertThat(result).isTrue();
}
@Test
void shouldReturnFalseIfNotConfigured() {
ReflectionTestUtils.setField(listener, "smartDocumentsProperties", Optional.empty());
var result = listener.isKielEnvironment();
assertThat(result).isFalse();
}
@Test
void shouldReturnFalseIfNotKiel() {
when(smartDocumentsProperties.getTemplateGroup()).thenReturn("NotKiel");
ReflectionTestUtils.setField(listener, "smartDocumentsProperties", Optional.of(smartDocumentsProperties));
var result = listener.isKielEnvironment();
assertThat(result).isFalse();
}
}
@Nested @Nested
class TestCreateBescheidRequest { class TestCreateBescheidRequest {
......
...@@ -197,6 +197,10 @@ spec: ...@@ -197,6 +197,10 @@ spec:
- name: ozgcloud_feature_bescheid_enableDummyDocumentProcessor - name: ozgcloud_feature_bescheid_enableDummyDocumentProcessor
value: {{ quote (((.Values.ozgcloud).feature).bescheid).enableDummyDocumentProcessor }} value: {{ quote (((.Values.ozgcloud).feature).bescheid).enableDummyDocumentProcessor }}
{{- end }} {{- end }}
{{- if (((.Values.ozgcloud).feature).bescheid).kielHackathonRoute }}
- name: ozgcloud_feature_bescheid_kielHackathonRoute
value: {{ quote (((.Values.ozgcloud).feature).bescheid).kielHackathonRoute }}
{{- end }}
{{- if (.Values.ozgcloud).processors}} {{- if (.Values.ozgcloud).processors}}
{{- range $processor_index, $processor := (.Values.ozgcloud).processors }} {{- range $processor_index, $processor := (.Values.ozgcloud).processors }}
......
#
# Copyright (C) 2024 Das Land Schleswig-Holstein vertreten durch den
# Ministerpräsidenten des Landes Schleswig-Holstein
# Staatskanzlei
# Abteilung Digitalisierung und zentrales IT-Management der Landesregierung
#
# Lizenziert unter der EUPL, Version 1.2 oder - sobald
# diese von der Europäischen Kommission genehmigt wurden -
# Folgeversionen der EUPL ("Lizenz");
# Sie dürfen dieses Werk ausschließlich gemäß
# dieser Lizenz nutzen.
# Eine Kopie der Lizenz finden Sie hier:
#
# https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
#
# Sofern nicht durch anwendbare Rechtsvorschriften
# gefordert oder in schriftlicher Form vereinbart, wird
# die unter der Lizenz verbreitete Software "so wie sie
# ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN -
# ausdrücklich oder stillschweigend - verbreitet.
# Die sprachspezifischen Genehmigungen und Beschränkungen
# unter der Lizenz sind dem Lizenztext zu entnehmen.
#
suite: deployment toggle to activate kiel hackathon route
release:
name: vorgang-manager
namespace: sh-helm-test
templates:
- templates/deployment.yaml
set:
imagePullSecret: image-pull-secret
ozgcloud:
environment: dev
feature:
bescheid:
kielHackathonRoute: true
tests:
- it: should enable kiel hackathon toggle
asserts:
- contains:
path: spec.template.spec.containers[0].env
content:
name: ozgcloud_feature_bescheid_kielHackathonRoute
value: "true"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment