aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-03 10:32:10 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-03 10:32:10 +0200
commit7c95141343a3157ee94a5306d9567beb6af10c90 (patch)
tree5a4cbdb2175a07ebd470e7bf90dbe70c62b907fa /src/main/java
parent4b6ce58f339d69c70ef746ceecae78bf7ed0f0ba (diff)
downloadmoa-zs-7c95141343a3157ee94a5306d9567beb6af10c90.tar.gz
moa-zs-7c95141343a3157ee94a5306d9567beb6af10c90.tar.bz2
moa-zs-7c95141343a3157ee94a5306d9567beb6af10c90.zip
TnvzHelper: Handle Edge Case and Add Test Cases
- TnvzHelper: Handle edge case where Mzs/DeliveryRequest/Sender/CorporateBody is missing (Reason: This field is in a <choice> with msg:SenderProfile, so if CorporateBody is missing the request still passes the schema validation). Handle case by rejecting missing CorporateBody and TnvzQuery activated. - Add test cases for TnvzHelper.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java6
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java2
-rw-r--r--src/main/java/at/gv/egiz/moazs/tnvz/TnvzHelper.java11
3 files changed, 9 insertions, 10 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java b/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java
index c5b73bb..26ea7dc 100644
--- a/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java
+++ b/src/main/java/at/gv/egiz/moazs/mzs/MzsValidator.java
@@ -16,7 +16,11 @@ public class MzsValidator {
* @return true if mandatory fields are present.
*/
public boolean isTnvzComplete(DeliveryRequestType request) {
- return (!request.getConfig().isPerformQueryPersonRequest()) || request.getTnvzMetaData() != null;
+ return !request.getConfig().isPerformQueryPersonRequest() ||
+ (request.getTnvzMetaData() != null
+ && request.getSender().getCorporateBody() != null);
+
+
}
/**
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
index fdb2ab8..6976738 100644
--- a/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
+++ b/src/main/java/at/gv/egiz/moazs/scheme/Mzs2MsgConverter.java
@@ -61,7 +61,7 @@ public class Mzs2MsgConverter {
//------------- SENDER ------------------
- public Sender convert(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Sender sender) {
+ private Sender convert(at.gv.zustellung.app2mzs.xsd.DeliveryRequestType.Sender sender) {
return senderBuilder()
.withSenderPerson(extractSenderPerson(sender))
.withLogo(sender.getLogo())
diff --git a/src/main/java/at/gv/egiz/moazs/tnvz/TnvzHelper.java b/src/main/java/at/gv/egiz/moazs/tnvz/TnvzHelper.java
index 3599362..f71b992 100644
--- a/src/main/java/at/gv/egiz/moazs/tnvz/TnvzHelper.java
+++ b/src/main/java/at/gv/egiz/moazs/tnvz/TnvzHelper.java
@@ -115,11 +115,6 @@ public class TnvzHelper {
private Sender extractSender(DeliveryRequestType.Sender sender) {
var corporateBody = sender.getCorporateBody();
- if (corporateBody == null) {
- //todo! implement this case
- throw MoaZSException.moaZSException("Not Implemented.");
- }
-
var mzsIdentification = corporateBody.getIdentification().get(0);
var msgIdentification = converter.convert(mzsIdentification);
@@ -135,9 +130,7 @@ public class TnvzHelper {
var builder = receiverBuilder();
- if (receiver.getIdentification() != null) {
- builder.withIdentification(converter.convert(receiver.getIdentification()));
- } else {
+ if (receiver.getIdentification() == null) {
builder
.withPerson(converter.convert(receiver.getPerson()))
.withAustrianAddressesOnly(receiver.getAustrianAddressesOnly());
@@ -149,6 +142,8 @@ public class TnvzHelper {
if (receiver.getPreAdviceNote() != null) {
builder.withNotificationAddressList(receiver.getPreAdviceNote().getNotificationAddressList());
}
+ } else {
+ builder.withIdentification(converter.convert(receiver.getIdentification()));
}
return builder.build();