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

WIP: OZG-6275 load antworten aber nicht speichern

parent df3c8d12
Branches
Tags
No related merge requests found
......@@ -56,9 +56,7 @@ public class MukPostfachRemoteService implements PostfachRemoteService {
@Override
public Stream<PostfachNachricht> getAllMessages() {
LOG.warn("Loading of PostfachNachrichten disabled right now.");
return Stream.of();
//return elsterTransferService.getAllMessages();
return elsterTransferService.getAllMessages();
}
@Override
......
......@@ -24,7 +24,6 @@ package de.ozgcloud.nachrichten.postfach.muk.transfer;
import static de.ozgcloud.nachrichten.postfach.muk.transfer.MukPostfachMessageMapper.*;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -47,7 +46,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import de.ozgcloud.apilib.file.OzgCloudFile;
import de.ozgcloud.apilib.file.OzgCloudFileId;
import de.ozgcloud.apilib.file.OzgCloudUploadFile;
import de.ozgcloud.common.binaryfile.TempFileUtils;
import de.ozgcloud.common.errorhandling.TechnicalException;
......@@ -199,8 +197,10 @@ public class ElsterTransferRemoteService {
public Stream<PostfachNachricht> getAllMessages() {
var antworten = loadAntworten();
return antworten.getDatensaetze().stream()
.map(this::getAntwort).filter(nachricht -> nachricht.getVorgangId() != null);
/*return antworten.getDatensaetze().stream()
.map(this::getAntwort).filter(nachricht -> nachricht.getVorgangId() != null);*/
LOG.warn("Saving of Antworten is disabled right now, returning an empty stream");
return Stream.of();
}
public AntwortDetailsList loadAntworten() {
......@@ -286,7 +286,7 @@ public class ElsterTransferRemoteService {
}
Optional<String> storeToOzgCloud(DownloadAnhangDetails downloadAnhangDetails, String vorgangId, ByteArrayInputStream dataIn) throws IOException {
OzgCloudFileId ozgCloudFileId;
/*OzgCloudFileId ozgCloudFileId;
try (BufferedInputStream dataStream = new BufferedInputStream(dataIn)) {
ozgCloudFileId = attachmentService.store(createOzgCloudUploadFile(downloadAnhangDetails, vorgangId), dataStream);
......@@ -297,6 +297,8 @@ public class ElsterTransferRemoteService {
}
LOG.error("Received no OzgCloudFileId when saving attachment {} to vorgangId {}", downloadAnhangDetails, vorgangId);
*/
LOG.warn("Saving attachment {} to vorgangId {} is disabled right now", downloadAnhangDetails, vorgangId);
return Optional.empty();
}
}
......
......@@ -367,6 +367,7 @@ class ElsterTransferRemoteServiceTest {
}
@Test
@Disabled("Saving of Antworten is disabled right now")
void shouldHavePostfachNachricht() {
var antwortList = elsterTransferService.getAllMessages().toList();
......@@ -375,61 +376,6 @@ class ElsterTransferRemoteServiceTest {
}
}
@Nested
class TestCreatingNachricht {
PostfachNachricht nachricht;
@BeforeEach
void setUp() {
when(elsterTransferService.loadAntworten()).thenReturn(AntwortDetailsTestFactory.createAntwortDetailsList());
when(postfachProperties.getReplySubjectPrefix()).thenReturn("Antwort");
when(postfachProperties.getBody()).thenReturn("Body");
nachricht = elsterTransferService.getAllMessages().toList().getFirst();
}
/*PostfachNachricht.FIELD_VORGANG_ID, nachricht.getVorgangId(),
PostfachNachricht.FIELD_CREATED_AT, nachricht.getCreatedAt().format(DateTimeFormatter.ISO_DATE_TIME),
PostfachNachricht.FIELD_DIRECTION, nachricht.getDirection().name(),
PostfachNachricht.FIELD_REPLY_OPTION, nachricht.getReplyOption().name(),
PostfachNachricht.FIELD_SUBJECT, nachricht.getSubject(),
PostfachNachricht.FIELD_MAIL_BODY, nachricht.getMailBody(),
PostfachNachricht.FIELD_ATTACHMENTS, nachricht.getAttachments()));*/
@Test
void shouldHaveVorgangId() {
assertThat(nachricht.getVorgangId()).isNotNull();
}
@Test
void shouldHaveCreatedAt() {
assertThat(nachricht.getCreatedAt()).isNotNull();
}
@Test
void shouldHaveDirection() {
assertThat(nachricht.getDirection()).isEqualTo(PostfachNachricht.Direction.IN);
}
@Test
void shouldHaveReplyOption() {
assertThat(nachricht.getReplyOption()).isNotNull();
}
@Test
void shouldHaveSubject() {
assertThat(nachricht.getSubject()).isNotNull();
}
@Test
void shouldHaveMailBody() {
assertThat(nachricht.getMailBody()).isNotNull();
}
@Test
void shouldHaveAttachments() {
assertThat(nachricht.getAttachments()).isNotNull();
}
}
@Nested
class TestExceptionHandling {
byte[] data = "test data".getBytes();
......@@ -508,7 +454,7 @@ class ElsterTransferRemoteServiceTest {
class TestSaveFile {
@Test
void shouldExtractVorgangIdFromDateibezeichnung() throws IOException {
when(attachmentService.store(any(), any())).thenReturn(new OzgCloudFileId(UUID.randomUUID().toString()));
//when(attachmentService.store(any(), any())).thenReturn(new OzgCloudFileId(UUID.randomUUID().toString()));
elsterTransferService.saveAnhang("Test,Data".getBytes(), AntwortDetailsTestFactory.createDownloadAnhangDetails(), null);
......@@ -517,11 +463,11 @@ class ElsterTransferRemoteServiceTest {
@Test
void shouldSaveAttachment() {
when(attachmentService.store(any(), any())).thenReturn(new OzgCloudFileId(UUID.randomUUID().toString()));
//when(attachmentService.store(any(), any())).thenReturn(new OzgCloudFileId(UUID.randomUUID().toString()));
var fileIdOpt = elsterTransferService.saveAnhang("Test,Data".getBytes(), AntwortDetailsTestFactory.createDownloadAnhangDetails(), null);
assertThat(fileIdOpt).isPresent();
assertThat(fileIdOpt).isNotPresent();
}
}
}
\ 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