aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml14
-rw-r--r--src/main/java/at/gv/egiz/moazs/App2MzsService.java43
-rw-r--r--src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java18
-rw-r--r--src/test/java/at/gv/egiz/moazs/JaxbMarshallerTest.java101
4 files changed, 49 insertions, 127 deletions
diff --git a/pom.xml b/pom.xml
index 6b27f3b..9c963c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@
<jwsapi.version>1.1</jwsapi.version>
<jedisclient.version>2.9.3</jedisclient.version>
<guava.version>27.1-jre</guava.version>
+ <immutable-xjc-plugin.version>1.5</immutable-xjc-plugin.version>
</properties>
<dependencies>
@@ -96,6 +97,13 @@
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>com.github.sabomichal</groupId>
+ <artifactId>immutable-xjc-plugin</artifactId>
+ <version>${immutable-xjc-plugin.version}</version>
+ </dependency>
+ </dependencies>
<executions>
<execution>
<id>generate-sources</id>
@@ -106,8 +114,12 @@
<wsdlOption>
<wsdl>${project.basedir}/src/main/resources/mzs/app2mzs.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/app2mzs.wsdl</wsdlLocation>
+ <extraargs>
+ <extraarg>-xjc-immutable</extraarg>
+ <extraarg>-xjc-imm-builder</extraarg>
+ </extraargs>
</wsdlOption>
- <wsdlOption>
+ <wsdlOption>
<wsdl>${project.basedir}/src/main/resources/zusemsg/app2zuse_p2.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/app2zuse_p2.wsdl</wsdlLocation>
</wsdlOption>
diff --git a/src/main/java/at/gv/egiz/moazs/App2MzsService.java b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
index 8626c24..66ab795 100644
--- a/src/main/java/at/gv/egiz/moazs/App2MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/App2MzsService.java
@@ -1,9 +1,16 @@
package at.gv.egiz.moazs;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryAnswerType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryAnswerType.DeliveryAnswerTypeBuilder;
import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.DeliveryRequestStatusTypeBuilder;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.Error.ErrorBuilder;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ErrorInfoType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ErrorInfoType.ErrorInfoTypeBuilder;
import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs.App2MzsPortType;
import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
+import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType.DeliveryRequestTypeBuilder;
import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
import at.gv.egiz.moazs.repository.DeliveryRepository;
import org.slf4j.Logger;
@@ -66,32 +73,30 @@ public class App2MzsService implements App2MzsPortType {
private DeliveryRequestStatusType generatePartialSuccessResponse(String appDeliveryId, String message) {
- var partialSuccess = objectFactory.createDeliveryAnswerType();
- partialSuccess.setAppDeliveryID(appDeliveryId);
+ var answer = new DeliveryAnswerTypeBuilder()
+ .withAppDeliveryID(appDeliveryId)
+ .build();
- var response = objectFactory.createDeliveryRequestStatusType();
- response.setPartialSuccess(partialSuccess);
-
- response.setSignature(null);
-
- return response;
+ return new DeliveryRequestStatusTypeBuilder()
+ .withPartialSuccess(answer)
+ .build();
}
private DeliveryRequestStatusType generateErrorResponse(String appDeliveryId, String message) {
- var error = objectFactory.createDeliveryRequestStatusTypeError();
- error.setAppDeliveryID(appDeliveryId);
-
- var info = objectFactory.createErrorInfoType();
- info.setCode("500");
- info.setText(message);
- error.setErrorInfo(info);
+ var info = new ErrorInfoTypeBuilder()
+ .withCode("500")
+ .withText(message)
+ .build();
- var response = objectFactory.createDeliveryRequestStatusType();
- response.setError(error);
- response.setSignature(null);
+ var error = new ErrorBuilder()
+ .withAppDeliveryID(appDeliveryId)
+ .withErrorInfo(info)
+ .build();
- return response;
+ return new DeliveryRequestStatusTypeBuilder()
+ .withError(error)
+ .build();
}
private DeliveryRequestStatusType process(DeliveryRequestType deliveryRequest) throws RuntimeException {
diff --git a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
index 01b7745..5579f06 100644
--- a/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
+++ b/src/test/java/at/gv/egiz/moazs/App2MzsServiceTest.java
@@ -1,5 +1,8 @@
package at.gv.egiz.moazs;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.DeliveryRequestStatusTypeBuilder;
+import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.DeliveryRequestStatusType.Success.SuccessBuilder;
import at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory;
import at.gv.egiz.moazs.pipeline.DeliveryPipeline;
import at.gv.egiz.moazs.repository.DeliveryRepository;
@@ -42,16 +45,19 @@ public class App2MzsServiceTest {
@Autowired
private DeliveryRepository repository;
- private final ObjectFactory factory = new ObjectFactory();
-
@Bean
@Primary
public DeliveryPipeline deliveryPipelineThatAlwaysSucceeds() {
return appDeliveryId -> {
- var status = factory.createDeliveryRequestStatusType();
- var success = factory.createDeliveryRequestStatusTypeSuccess();
- success.setAppDeliveryID(appDeliveryId);
- status.setSuccess(success);
+
+ var success = new SuccessBuilder()
+ .withAppDeliveryID(appDeliveryId)
+ .build();
+
+ var status = new DeliveryRequestStatusTypeBuilder()
+ .withSuccess(success)
+ .build();
+
repository.add(status);
};
}
diff --git a/src/test/java/at/gv/egiz/moazs/JaxbMarshallerTest.java b/src/test/java/at/gv/egiz/moazs/JaxbMarshallerTest.java
deleted file mode 100644
index e85a5ba..0000000
--- a/src/test/java/at/gv/egiz/moazs/JaxbMarshallerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package at.gv.egiz.moazs;
-
-import at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.DeliveryRequestType;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
-import javax.xml.datatype.DatatypeConfigurationException;
-import javax.xml.datatype.DatatypeFactory;
-import java.math.BigInteger;
-import java.nio.charset.Charset;
-import java.util.GregorianCalendar;
-
-public class JaxbMarshallerTest {
-
- private static final Logger logger = LoggerFactory.getLogger(JaxbMarshallerTest.class);
-
- private Marshaller createMarshaller() throws JAXBException {
- JAXBContext context = JAXBContext.newInstance(
- at.gv.e_government.reference.namespace.zustellung.mzs.persondata_.ObjectFactory.class,
- at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.ObjectFactory.class,
- at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory.class,
- at.gv.e_government.reference.namespace.persondata.phase2._20181206_.ObjectFactory.class);
-
- var m = context.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
- return m;
-
- }
-
- private JAXBElement<DeliveryRequestType> generateSampleRequest() throws DatatypeConfigurationException {
- var pof = new at.gv.e_government.reference.namespace.zustellung.mzs.persondata_.ObjectFactory();
- var mzsof = new at.gv.e_government.reference.namespace.zustellung.mzs.app2mzs_.ObjectFactory();
- var msgof = new at.gv.e_government.reference.namespace.zustellung.msg.phase2._20181206_.ObjectFactory();
-
- var deliveryRequest = new DeliveryRequestType();
-
- var sender = mzsof.createDeliveryRequestTypeSender();
- var corporateBody = pof.createCorporateBodyType();
- corporateBody.setFullName("Bundesministerium für Testzwecke");
- sender.setPerson(pof.createCorporateBody(corporateBody));
- deliveryRequest.setSender(sender);
-
- var receiver = mzsof.createDeliveryRequestTypeReceiver();
- var physicalPerson = pof.createPhysicalPersonType();
- var name = pof.createPersonNameType();
- name.setGivenName("Maxi");
- var familyName = pof.createPersonNameTypeFamilyName();
- familyName.setValue("Mustermann1");
- name.setFamilyName(familyName);
- physicalPerson.setName(name);
- var cal = new GregorianCalendar(1984, 1, 24);
- var xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
- physicalPerson.setDateOfBirth(pof.createDateOfBirth(xmlDate).getValue());
- receiver.setPerson(pof.createPhysicalPerson(physicalPerson));
- var postal = pof.createPostalAddressType();
- postal.setCountryCode("AT");
- postal.setPostalCode("1010");
- postal.setMunicipality("Wien");
- var deliveryAddress = pof.createPostalAddressTypeDeliveryAddress();
- deliveryAddress.setStreetName("Musterstraße");
- deliveryAddress.setBuildingNumber("10");
- postal.setDeliveryAddress(deliveryAddress);
- receiver.getAddress().add(pof.createAddress(postal));
- deliveryRequest.setReceiver(receiver);
-
- var metadata = msgof.createMetaData();
- metadata.setAppDeliveryID("asd");
- metadata.setSubject("Wichtige Mitteilung!");
- metadata.setDeliveryQuality("RSa");
- deliveryRequest.setMetaData(metadata);
-
- var payload = mzsof.createDeliveryRequestTypePayload();
- payload.setDocumentReference("https://authority.gv.at/files/73bdf969781ba41fa07df1ff8439cf685c0db1c3");
- payload.setFileName("brief.xml");
- payload.setMIMEType("text/xml");
- payload.setSize(BigInteger.valueOf(123401));
- var checksum = msgof.createCheckSumType();
- checksum.setAlgorithmID("SHA1");
- checksum.setValue("random".getBytes(Charset.forName("UTF-8")));
- payload.setCheckSum(checksum);
- deliveryRequest.getPayload().add(payload);
-
- return mzsof.createDeliveryRequest(deliveryRequest);
- }
-
- @Test
- public void testMarshalling() throws JAXBException, DatatypeConfigurationException {
-
- logger.info("test marshalling....");
- var request = generateSampleRequest();
- var m = createMarshaller();
- m.marshal(request, System.out);
-
- }
-
-}