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

Merge branch 'master' into OZG-3119_interne_usermanager_adresse

parents 1ad744a3 7b501160
Branches
Tags
No related merge requests found
......@@ -48,9 +48,6 @@ public class PostfachMailController {
@Autowired
private PostfachMailModelAssembler assembler;
@Autowired
private PostfachMailPdfService pdfService;
@Autowired
private VorgangController vorgangController;
@Autowired
......@@ -71,7 +68,7 @@ public class PostfachMailController {
}
StreamingResponseBody createDownloadStreamingBody(VorgangWithEingang vorgang) {
return out -> pdfService.getAllAsPdf(vorgang, out);
return out -> service.getAllAsPdf(vorgang, out);
}
ResponseEntity<StreamingResponseBody> buildResponseEntity(VorgangWithEingang vorgang, StreamingResponseBody responseBody) {
......
......@@ -24,7 +24,7 @@ class PostfachMailPdfService {
@Value(PostfachMailPdfService.PDF_TEMPLATE_PATH)
private Resource pdfTemplate;
public Object getAllAsPdf(VorgangWithEingang vorgang, OutputStream out) {
public OutputStream getAllAsPdf(VorgangWithEingang vorgang, OutputStream out) {
return pdfService.createPdf(getTemplate(), out, buildModel(vorgang));
}
......
package de.itvsh.goofy.postfach;
import java.io.OutputStream;
import java.util.Objects;
import java.util.stream.Stream;
......@@ -7,6 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import de.itvsh.goofy.common.errorhandling.ResourceNotFoundException;
import de.itvsh.goofy.vorgang.VorgangWithEingang;
import lombok.extern.log4j.Log4j2;
@Log4j2
......@@ -15,6 +17,9 @@ class PostfachMailService {
private Boolean isPostfachConfigured = null;
@Autowired
private PostfachMailPdfService pdfService;
@Autowired
private PostfachMailRemoteService remoteService;
......@@ -45,4 +50,8 @@ class PostfachMailService {
}
return isPostfachConfigured;
}
public OutputStream getAllAsPdf(VorgangWithEingang vorgang, OutputStream out) {
return pdfService.getAllAsPdf(vorgang, out);
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
......@@ -45,8 +46,6 @@ class PostfachMailControllerTest {
@Mock
private PostfachMailModelAssembler assembler;
@Mock
private PostfachMailPdfService pdfService;
@Mock
private VorgangController vorgangController;
@Mock
private BinaryFileController binaryFileController;
......@@ -95,6 +94,7 @@ class PostfachMailControllerTest {
}
}
@Disabled("FIXME OZG-2966")
@DisplayName("Get all as pdf")
@Nested
class TestGetAllAsPdf {
......@@ -119,7 +119,7 @@ class PostfachMailControllerTest {
void shouldCallService() throws Exception {
doRequest();
verify(pdfService).getAllAsPdf(eq(vorgang), any(OutputStream.class));
verify(service).getAllAsPdf(eq(vorgang), any(OutputStream.class));
}
@Test
......
package de.itvsh.goofy.postfach;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.io.OutputStream;
import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
......@@ -13,19 +15,22 @@ import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import static org.assertj.core.api.Assertions.*;
import de.itvsh.goofy.common.command.CommandTestFactory;
import de.itvsh.goofy.common.errorhandling.ResourceNotFoundException;
import de.itvsh.goofy.vorgang.VorgangHeaderTestFactory;
import de.itvsh.goofy.vorgang.VorgangWithEingang;
import de.itvsh.goofy.vorgang.VorgangWithEingangTestFactory;
class PostfachMailServiceTest {
@InjectMocks // NOSONAR
private PostfachMailService service;
@Mock
private PostfachMailPdfService pdfService;
@Mock
private PostfachMailRemoteService remoteService;
@DisplayName("Get all")
@Nested
class TestGetAll {
......@@ -37,6 +42,7 @@ class PostfachMailServiceTest {
}
}
@DisplayName("Find by id")
@Nested
class TestFindById {
......@@ -69,6 +75,7 @@ class PostfachMailServiceTest {
}
}
@DisplayName("Resend postfach mail")
@Nested
class TestResendPostfachMail {
......@@ -80,19 +87,19 @@ class PostfachMailServiceTest {
}
}
@DisplayName("Is postfach configured")
@Nested
class TestIsPostfachConfigured {
@Test
void shouldCallRemoteService() {
void shouldCallRemoteServiceOnMissingProperty() {
service.isPostfachConfigured();
verify(remoteService).isPostfachConfigured();
}
@DisplayName("if property is already set, no remoteservice call should be done")
@Test
void shouldNotCallRemoteService() throws Exception {
void shouldNotCallRemoteServiceOnExistingProperty() throws Exception {
setIsConfigured();
service.isPostfachConfigured();
......@@ -106,4 +113,21 @@ class PostfachMailServiceTest {
isPostfachConfigured.set(service, true);
}
}
@DisplayName("Get all as pdf")
@Nested
class TestGetAllAsPdf {
@Mock
private OutputStream outputStream;
private final VorgangWithEingang vorgang = VorgangWithEingangTestFactory.create();
@Test
void shouldCallPdfService() {
service.getAllAsPdf(vorgang, outputStream);
verify(pdfService).getAllAsPdf(vorgang, outputStream);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment