-
Notifications
You must be signed in to change notification settings - Fork 8
/
PeppolMLRBuilderTest.java
79 lines (69 loc) · 3.62 KB
/
PeppolMLRBuilderTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (C) 2023-2024 Philip Helger
* philip[at]helger[dot]com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http:https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.helger.peppol.mlr;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.helger.peppolid.factory.PeppolIdentifierFactory;
import oasis.names.specification.ubl.schema.xsd.applicationresponse_21.ApplicationResponseType;
/**
* Test class for class {@link PeppolMLRBuilder}.
*
* @author Philip Helger
*/
public final class PeppolMLRBuilderTest
{
private static final Logger LOGGER = LoggerFactory.getLogger (PeppolMLRBuilderTest.class);
@Test
public void testMinimalNoLine ()
{
final PeppolIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
final ApplicationResponseType aMLR = PeppolMLRBuilder.acceptance ()
.referenceId ("SBDH-12345")
.senderParticipantID (aIF.createParticipantIdentifierWithDefaultScheme ("9915:mlr-sender"))
.receiverParticipantID (aIF.createParticipantIdentifierWithDefaultScheme ("9915:mlr-receiver"))
.build ();
assertNotNull (aMLR);
assertNotNull (new PeppolMLRMarshaller ().getAsDocument (aMLR));
if (false)
LOGGER.info (new PeppolMLRMarshaller ().setFormattedOutput (true).getAsString (aMLR));
if (false)
new PeppolMLRMarshaller ().setFormattedOutput (true).write (aMLR, new File ("generated/mlr1.xml"));
}
@Test
public void testMinimalWithOneLine ()
{
final PeppolIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE;
final ApplicationResponseType aMLR = PeppolMLRBuilder.rejection ()
.referenceId ("SBDH-12345")
.senderParticipantID (aIF.createParticipantIdentifierWithDefaultScheme ("9915:mlr-sender"))
.receiverParticipantID (aIF.createParticipantIdentifierWithDefaultScheme ("9915:mlr-receiver"))
.addLineResponse (PeppolMLRLineResponseBuilder.rejection ()
.errorField ("Invoice/ID")
.statusReasonCodeBusinessRuleViolationFatal ()
.description ("The ID seems to be missing"))
.build ();
assertNotNull (aMLR);
assertNotNull (new PeppolMLRMarshaller ().getAsDocument (aMLR));
if (false)
LOGGER.info (new PeppolMLRMarshaller ().setFormattedOutput (true).getAsString (aMLR));
if (false)
new PeppolMLRMarshaller ().setFormattedOutput (true).write (aMLR, new File ("generated/mlr2.xml"));
}
}