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

OZG-6922 Try reproducing xdomea bug with ClearingStelle data

parent 3534727e
No related tags found
No related merge requests found
......@@ -9,12 +9,16 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;
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;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
......@@ -215,6 +219,34 @@ class XtaITCase {
assertThat(eingang.getNumberOfRepresentations()).isEqualTo(1);
}
@DisplayName("should not fail")
@ParameterizedTest
@MethodSource("antragnums")
void shouldNotFail(int num) {
mockNachrichtenBroker("antrag_with_potential_error_%d.zip".formatted(num));
runner.runGetXtaMessages();
var eingang = captureEingang();
assertThat(eingang.getNumberOfRepresentations()).isGreaterThan(1);
}
static Stream<Arguments> antragnums() {
return IntStream.range(0, 58)
.mapToObj(Arguments::of);
}
@DisplayName("should not fail2")
@Test
void shouldNotFail2() {
mockNachrichtenBroker("07bddd38-5b87-431f-a6d6-3ec19435f655_N_fdd670ce-538d-43fe-9ad7-0d5378e57223_Geschaeftsgang.Geschaeftsgang.0201.zip");
runner.runGetXtaMessages();
var eingang = captureEingang();
assertThat(eingang.getNumberOfRepresentations()).isGreaterThan(1);
}
private GrpcEingang captureEingang() {
verify(vorgangRemoteService, times(1))
.createVorgang(
......
......@@ -8,14 +8,14 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.ZonedDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.codec.Resources;
......@@ -25,23 +25,14 @@ import de.ozgcloud.common.binaryfile.TempFileUtils;
public class XtaResponseTestFactory {
public static final Map<String, String> MESSAGE_TYPE_BY_ATTACHMENT_FILENAME = Map.of(
"mantelantrag_without_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"dfoerdermittel_without_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"brauchtumsfeuer_without_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"versammlungsanzeige.xml", "fim.S17000652.17000652001004",
"mantelantrag_with_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"dfoerdermittel_with_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"brauchtumsfeuer_with_anlage.zip", "Geschaeftsgang.Geschaeftsgang.0201",
"waffenschein.zip", "Geschaeftsgang.Geschaeftsgang.0201"
);
private static final Map<String, String> MESSAGE_ID_BY_ATTACHMENT_FILENAME = MESSAGE_TYPE_BY_ATTACHMENT_FILENAME
.keySet().stream()
.collect(Collectors.toMap(name -> name, name -> generateMessageID()));
private static String generateMessageID() {
return "urn:de:xta:messageid:dataport_xta_210:%s".formatted(UUID.randomUUID().toString());
private static final MessageDigest MD5_DIGEST;
static {
try {
MD5_DIGEST = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
}
public static XtaMessageMetaDatasAndHeader createEmptyGetStatusListResponse() {
......@@ -56,8 +47,8 @@ public class XtaResponseTestFactory {
var messageMetaDataItems = xtaAttachmentFileNames.stream()
.map(name ->
XtaMessageMetaData.builder()
.messageId(new XtaMessageId(MESSAGE_ID_BY_ATTACHMENT_FILENAME.get(name)))
.messageType(MESSAGE_TYPE_BY_ATTACHMENT_FILENAME.get(name))
.messageId(new XtaMessageId(getMessageId(name)))
.messageType(getMessageType(name))
.origin(ZonedDateTime.now())
.delivery(ZonedDateTime.now())
.build()
......@@ -93,9 +84,13 @@ public class XtaResponseTestFactory {
var attachmentResourcePath = getAttachmentFilePath(xtaAttachmentFileName);
if (xtaAttachmentFileName.endsWith(".zip")) {
try {
return new FileInputStream(
createAttachmentZipFile(
attachmentResourcePath.replace(".zip", "")));
if (xtaAttachmentFileName.equals("07bddd38-5b87-431f-a6d6-3ec19435f655_N_fdd670ce-538d-43fe-9ad7-0d5378e57223_Geschaeftsgang.Geschaeftsgang.0201.zip")) {
return XtaResponseTestFactory.class.getClassLoader().getResourceAsStream("07bddd38-5b87-431f-a6d6-3ec19435f655_N_fdd670ce-538d-43fe-9ad7-0d5378e57223_Geschaeftsgang.Geschaeftsgang.0201.zip");
} else {
return new FileInputStream(
createAttachmentZipFile(
attachmentResourcePath.replace(".zip", "")));
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
......@@ -128,10 +123,18 @@ public class XtaResponseTestFactory {
}
private static String getMessageType(String xtaAttachmentFileName) {
return Objects.requireNonNull(
MESSAGE_TYPE_BY_ATTACHMENT_FILENAME.get(xtaAttachmentFileName),
"Xta-message type for '%s' has to be configured!".formatted(xtaAttachmentFileName)
if (xtaAttachmentFileName.equals("versammlungsanzeige.xml")) {
return "fim.S17000652.17000652001004";
}
return "Geschaeftsgang.Geschaeftsgang.0201";
}
private static String getMessageId(String xtaAttachmentFileName) {
var buffer = ByteBuffer.wrap(
MD5_DIGEST.digest(xtaAttachmentFileName.getBytes(StandardCharsets.UTF_8))
);
var uuid = new UUID(buffer.getLong(), buffer.getLong());
return "urn:de:xta:messageid:dataport_xta_210:%s".formatted(uuid.toString());
}
private static String getAttachmentFilePath(String xtaAttachmentFileName) {
......
#!/bin/bash
index=0
for zipfile in /mnt/hgfs/SharedLocal/XTA/Bug-xdomea-not-found/*.zip
do
unzip -d "$HOME/IdeaProjects/eingang-manager/xta-adapter/src/test/resources/mock-responses/getMessage/Geschaeftsgang.Geschaeftsgang.0201/antrag_with_potential_error_$index" "$zipfile"
((index++))
done
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