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
Branches
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.*;
import static org.mockito.Mockito.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
......@@ -67,6 +66,8 @@ class ForwardingVorgangWithEingangProcessorTest {
@Test
void shouldCallIsForwardableByOzgCloud() {
doReturn(false).when(processor).isForwardableByOzgCloud(any());
processor.process(EntityModel.of(vorgang));
verify(processor).isForwardableByOzgCloud(vorgang);
......@@ -74,6 +75,7 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested
class TestOnIsNotForwardableByOzgCloud {
@BeforeEach
void givenIsNotForwardableByOzgCloud() {
doReturn(false).when(processor).isForwardableByOzgCloud(any());
......@@ -89,6 +91,7 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested
class TestOnIsForwardableByOzgCloud {
@BeforeEach
void givenIsNotForwardableByOzgCloud() {
doReturn(true).when(processor).isForwardableByOzgCloud(any());
......@@ -111,33 +114,40 @@ class ForwardingVorgangWithEingangProcessorTest {
@Nested
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
@EnumSource
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);
assertThat(link).isEmpty();
}
@DisplayName("with role EinheitlicherAnsprechpartner")
@Nested
class TestWithRoleEinheitlicherAnsprechpartner {
@BeforeEach
void init() {
when(userService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER)).thenReturn(true);
when(userService.hasRole(any())).thenReturn(true);
}
@DisplayName("should be present in any Status")
@ParameterizedTest
@EnumSource()
void shouldBePresent(VorgangStatus status) {
@EnumSource
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);
assertThat(link).isPresent().get().extracting(Link::getHref)
.isEqualTo("/api/forwardings?vorgangId=" + VorgangHeaderTestFactory.ID);
assertThat(link).isPresent().get().extracting(Link::getHref).isEqualTo(expectedHref);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment