Skip to content
Snippets Groups Projects
Commit 2d7bf981 authored by Felix Reichenbach's avatar Felix Reichenbach
Browse files

OZG-7474 don't show forward link for EA and Poststelle roles

parent 5b25146f
Branches
Tags
1 merge request!11OZG-7474 OZG-7610 add forward by ozg cloud link, move forward by email into new processor
......@@ -39,13 +39,17 @@ class ForwardingVorgangWithEingangProcessor implements RepresentationModelProces
}
boolean isForwardableByOzgCloud(VorgangWithEingang vorgang) {
return featureToggleProperties.isForwardByOzgCloudEnabled() && isStatusNeu(vorgang);
return featureToggleProperties.isForwardByOzgCloudEnabled() && isStatusNeu(vorgang) && isNotPoststelleOrEinheitlicherAnsprechpartner();
}
private boolean isStatusNeu(VorgangWithEingang vorgang) {
return vorgang.getStatus() == VorgangStatus.NEU;
}
boolean isNotPoststelleOrEinheitlicherAnsprechpartner() {
return userService.hasRole(UserRole.VERWALTUNG_POSTSTELLE) || userService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
}
private Link buildForwardByOzgCloudLink(VorgangWithEingang vorgang) {
return linkTo(methodOn(CommandController.CommandByRelationController.class).createCommand(vorgang.getId(), vorgang.getId(),
vorgang.getVersion(), null)).withRel(REL_FORWARD_BY_OZGCLOUD);
......
......@@ -182,6 +182,16 @@ class ForwardingVorgangWithEingangProcessorTest {
assertThat(forwardableByOzgCloud).isFalse();
}
@ParameterizedTest
@EnumSource
void shouldNotCallIsNotPoststelleOrEinheitlicherAnsprechpartner(VorgangStatus status) {
var vorgang = VorgangWithEingangTestFactory.createBuilder().status(status).build();
processor.isForwardableByOzgCloud(vorgang);
verify(processor, never()).isNotPoststelleOrEinheitlicherAnsprechpartner();
}
}
@Nested
......@@ -192,6 +202,8 @@ class ForwardingVorgangWithEingangProcessorTest {
when(featureToggleProperties.isForwardByOzgCloudEnabled()).thenReturn(true);
}
@Nested
class TestOnVorgangNotNeu {
@ParameterizedTest
@EnumSource(mode = Mode.EXCLUDE, names = { "NEU" })
void shouldReturnFalseOnVorgangStatusNotNeu(VorgangStatus status) {
......@@ -202,14 +214,76 @@ class ForwardingVorgangWithEingangProcessorTest {
assertThat(forwardableByOzgCloud).isFalse();
}
@ParameterizedTest
@EnumSource(mode = Mode.EXCLUDE, names = { "NEU" })
void shouldNotCallIsNotPoststelleOrEinheitlicherAnsprechpartner(VorgangStatus status) {
var vorgang = VorgangWithEingangTestFactory.createBuilder().status(status).build();
processor.isForwardableByOzgCloud(vorgang);
verify(processor, never()).isNotPoststelleOrEinheitlicherAnsprechpartner();
}
}
@Nested
class TestOnVorgangIsNeu {
private final VorgangWithEingang newVorgang = VorgangWithEingangTestFactory.createBuilder().status(VorgangStatus.NEU).build();
@Test
void shouldReturnTrueOnVorgangStatusNeu() {
var vorgang = VorgangWithEingangTestFactory.createBuilder().status(VorgangStatus.NEU).build();
void shouldCallIsNotPoststelleOrEinheitlicherAnsprechpartner() {
processor.isForwardableByOzgCloud(newVorgang);
var forwardableByOzgCloud = processor.isForwardableByOzgCloud(vorgang);
verify(processor).isNotPoststelleOrEinheitlicherAnsprechpartner();
}
@ParameterizedTest
@ValueSource(booleans = { true, false })
void shouldReturnValueOfisNotPoststelleOrEinheitlicherAnsprechpartner(boolean isNotPoststelleOrEinheitlicherAnsprechpartner) {
doReturn(isNotPoststelleOrEinheitlicherAnsprechpartner).when(processor).isNotPoststelleOrEinheitlicherAnsprechpartner();
assertThat(forwardableByOzgCloud).isTrue();
var forwardableByOzgCloud = processor.isForwardableByOzgCloud(newVorgang);
assertThat(forwardableByOzgCloud).isEqualTo(isNotPoststelleOrEinheitlicherAnsprechpartner);
}
}
}
}
@Nested
class TestIsNotPoststelleOrEinheitlicherAnsprechpartner {
private static final String UNKOWN_ROLE = "UNKOWN_ROLE";
@BeforeEach
void mock() {
when(userService.hasRole(any())).thenAnswer(invocation -> {
var role = invocation.getArgument(0, String.class);
return role == UserRole.EINHEITLICHER_ANSPRECHPARTNER || role == UserRole.VERWALTUNG_POSTSTELLE;
});
}
@Test
void shouldCallUserServiceForCurrentRole() {
processor.isForwardableByEmail();
verify(userService).hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
}
@ParameterizedTest
@ValueSource(strings = { UserRole.EINHEITLICHER_ANSPRECHPARTNER, UserRole.VERWALTUNG_POSTSTELLE })
void shouldReturnFalse(String role) {
var isNotPoststelleOrEinheitlicherAnsprechpartner = processor.isNotPoststelleOrEinheitlicherAnsprechpartner();
assertThat(isNotPoststelleOrEinheitlicherAnsprechpartner).isTrue();
}
@ParameterizedTest
@ValueSource(strings = { UserRole.VERWALTUNG_LOESCHEN, UserRole.VERWALTUNG_USER, UNKOWN_ROLE })
void shouldReturnTrue(String role) {
var isNotPoststelleOrEinheitlicherAnsprechpartner = processor.isNotPoststelleOrEinheitlicherAnsprechpartner();
assertThat(isNotPoststelleOrEinheitlicherAnsprechpartner).isTrue();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment