Skip to content
Snippets Groups Projects
Commit 930b062c authored by Jan Zickermann's avatar Jan Zickermann
Browse files

OZG-5776 fim: Put xml-form into `fim_files` attachment group

parent 86fa5126
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import org.springframework.stereotype.Component;
import de.ozgcloud.eingang.common.formdata.FormData;
import de.ozgcloud.eingang.common.formdata.IncomingFile;
import de.ozgcloud.eingang.common.formdata.IncomingFileGroup;
import de.ozgcloud.eingang.common.vorgang.VorgangNummerSupplier;
import de.ozgcloud.eingang.xta.RepresentationsAttachmentsPair;
import de.ozgcloud.eingang.xta.XtaMessageHandler;
......@@ -20,6 +21,8 @@ import de.ozgcloud.eingang.xta.XtaMessageMetaData;
public class FimXtaMessageHandler implements XtaMessageHandler {
static final String ALL_FIM_MESSAGES_PREFIX = "fim.";
static final String FIM_FILE_GROUP_NAME = "fim_files";
@Autowired
private XtaMessageMapper xtaMessageMapper;
......@@ -37,8 +40,11 @@ public class FimXtaMessageHandler implements XtaMessageHandler {
RepresentationsAttachmentsPair getRepresentationsAttachmentsPair(List<IncomingFile> incomingFiles) {
return RepresentationsAttachmentsPair.builder()
.representations(incomingFiles)
.attachments(emptyList())
.representations(emptyList())
.attachment(IncomingFileGroup.builder()
.name(FIM_FILE_GROUP_NAME)
.files(incomingFiles)
.build())
.build();
}
......
......@@ -5,10 +5,11 @@ import java.util.List;
import de.ozgcloud.eingang.common.formdata.IncomingFile;
import de.ozgcloud.eingang.common.formdata.IncomingFileGroup;
import lombok.Builder;
import lombok.Singular;
@Builder
public record RepresentationsAttachmentsPair(
List<IncomingFile> representations,
List<IncomingFileGroup> attachments
@Singular List<IncomingFileGroup> attachments
) {
}
package de.ozgcloud.eingang.fim;
import static de.ozgcloud.eingang.fim.FimXtaMessageHandler.*;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
......@@ -15,6 +16,7 @@ import org.mockito.Spy;
import de.ozgcloud.eingang.common.formdata.FormData;
import de.ozgcloud.eingang.common.formdata.IncomingFile;
import de.ozgcloud.eingang.common.formdata.IncomingFileGroup;
import de.ozgcloud.eingang.common.vorgang.VorgangNummerSupplier;
import de.ozgcloud.eingang.xta.RepresentationsAttachmentsPair;
import de.ozgcloud.eingang.xta.XtaMessageMapper;
......@@ -77,20 +79,41 @@ class FimXtaMessageHandlerTest {
incomingFiles = List.of(incomingFile1, incomingFile2);
}
@DisplayName("should return representations")
@DisplayName("should return empty representations")
@Test
void shouldReturnRepresentations() {
var result = handler.getRepresentationsAttachmentsPair(incomingFiles);
assertThat(result.representations()).containsExactly(incomingFile1, incomingFile2);
assertThat(result.representations()).isEmpty();
}
@DisplayName("should return empty attachments")
@DisplayName("should return one attachment group")
@Test
void shouldReturnEmptyAttachments() {
var result = handler.getRepresentationsAttachmentsPair(incomingFiles);
assertThat(result.attachments()).isEmpty();
assertThat(result.attachments()).hasSize(1);
}
@DisplayName("should have name")
@Test
void shouldHaveName() {
var group = firstGroup();
assertThat(group.getName()).isEqualTo(FIM_FILE_GROUP_NAME);
}
@DisplayName("should have attachment files")
@Test
void shouldHaveAttachmentFiles() {
var result = firstGroup();
assertThat(result.getFiles()).containsExactly(incomingFile1, incomingFile2);
}
private IncomingFileGroup firstGroup() {
var result = handler.getRepresentationsAttachmentsPair(incomingFiles);
return result.attachments().getFirst();
}
}
......
......@@ -178,15 +178,15 @@ class XtaITCase {
assertThat(vorgangNummer).hasSize(9);
}
@DisplayName("should have one representation for FIM")
@DisplayName("should have one attachment for FIM")
@Test
void shouldHaveOneRepresentationForFim() {
void shouldHaveOneAttachmentForFim() {
mockNachrichtenBroker("versammlungsanzeige.xml");
runner.runGetXtaMessages();
var eingang = captureEingang();
assertThat(eingang.getNumberOfRepresentations()).isEqualTo(1);
assertThat(eingang.getNumberOfAttachments()).isEqualTo(1);
}
private GrpcEingang captureEingang() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment