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

OZG-7474 apply code review comments

parent ec78a8cb
No related branches found
No related tags found
1 merge request!11OZG-7474 OZG-7610 add forward by ozg cloud link, move forward by email into new processor
...@@ -5,7 +5,6 @@ import static org.mockito.ArgumentMatchers.*; ...@@ -5,7 +5,6 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
...@@ -67,6 +66,8 @@ class ForwardingVorgangWithEingangProcessorTest { ...@@ -67,6 +66,8 @@ class ForwardingVorgangWithEingangProcessorTest {
@Test @Test
void shouldCallIsForwardableByOzgCloud() { void shouldCallIsForwardableByOzgCloud() {
doReturn(false).when(processor).isForwardableByOzgCloud(any());
processor.process(EntityModel.of(vorgang)); processor.process(EntityModel.of(vorgang));
verify(processor).isForwardableByOzgCloud(vorgang); verify(processor).isForwardableByOzgCloud(vorgang);
...@@ -74,6 +75,7 @@ class ForwardingVorgangWithEingangProcessorTest { ...@@ -74,6 +75,7 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested @Nested
class TestOnIsNotForwardableByOzgCloud { class TestOnIsNotForwardableByOzgCloud {
@BeforeEach @BeforeEach
void givenIsNotForwardableByOzgCloud() { void givenIsNotForwardableByOzgCloud() {
doReturn(false).when(processor).isForwardableByOzgCloud(any()); doReturn(false).when(processor).isForwardableByOzgCloud(any());
...@@ -89,6 +91,7 @@ class ForwardingVorgangWithEingangProcessorTest { ...@@ -89,6 +91,7 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested @Nested
class TestOnIsForwardableByOzgCloud { class TestOnIsForwardableByOzgCloud {
@BeforeEach @BeforeEach
void givenIsNotForwardableByOzgCloud() { void givenIsNotForwardableByOzgCloud() {
doReturn(true).when(processor).isForwardableByOzgCloud(any()); doReturn(true).when(processor).isForwardableByOzgCloud(any());
...@@ -111,33 +114,40 @@ class ForwardingVorgangWithEingangProcessorTest { ...@@ -111,33 +114,40 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested @Nested
class TestForwardingLink { class TestForwardingLink {
@DisplayName("should NOT be present in other Role then EA") @Test
void shouldCallUserServiceForCurrentRole() {
processor.process(EntityModel.of(VorgangWithEingangTestFactory.create()));
verify(userService).hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
}
@ParameterizedTest @ParameterizedTest
@EnumSource @EnumSource
void shouldNotBePresentWithoutRole(Vorgang.VorgangStatus status) { void shouldNotBePresentWithoutRole(Vorgang.VorgangStatus status) {
when(userService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER)).thenReturn(false); when(userService.hasRole(any())).thenReturn(false);
var link = processor.process(buildVorgangInStatus(status)).getLink(ForwardingVorgangWithEingangProcessor.REL_FORWARD_BY_EMAIL); var link = processor.process(buildVorgangInStatus(status)).getLink(ForwardingVorgangWithEingangProcessor.REL_FORWARD_BY_EMAIL);
assertThat(link).isEmpty(); assertThat(link).isEmpty();
} }
@DisplayName("with role EinheitlicherAnsprechpartner")
@Nested @Nested
class TestWithRoleEinheitlicherAnsprechpartner { class TestWithRoleEinheitlicherAnsprechpartner {
@BeforeEach @BeforeEach
void init() { void init() {
when(userService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER)).thenReturn(true); when(userService.hasRole(any())).thenReturn(true);
} }
@DisplayName("should be present in any Status")
@ParameterizedTest @ParameterizedTest
@EnumSource() @EnumSource
void shouldBePresent(VorgangStatus status) { void shouldBePresentOnAnyStatus(VorgangStatus status) {
var expectedHref = UriComponentsBuilder.fromUriString(ForwardingController.LIST_PATH)
.queryParam(ForwardingController.PARAM_VORGANG_ID, VorgangHeaderTestFactory.ID).build().toString();
var link = processor.process(buildVorgangInStatus(status)).getLink(ForwardingVorgangWithEingangProcessor.REL_FORWARD_BY_EMAIL); var link = processor.process(buildVorgangInStatus(status)).getLink(ForwardingVorgangWithEingangProcessor.REL_FORWARD_BY_EMAIL);
assertThat(link).isPresent().get().extracting(Link::getHref) assertThat(link).isPresent().get().extracting(Link::getHref).isEqualTo(expectedHref);
.isEqualTo("/api/forwardings?vorgangId=" + VorgangHeaderTestFactory.ID);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment