Skip to content

Commit 749df69

Browse files
add integration tests
1 parent 02f3661 commit 749df69

File tree

10 files changed

+517
-76
lines changed

10 files changed

+517
-76
lines changed

api/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,6 @@
119119
<artifactId>rest-assured</artifactId>
120120
<scope>test</scope>
121121
</dependency>
122-
123-
<dependency>
124-
<groupId>org.awaitility</groupId>
125-
<artifactId>awaitility</artifactId>
126-
<version>3.0.0</version>
127-
<scope>test</scope>
128-
</dependency>
129122
</dependencies>
130123
<build>
131124
<plugins>

api/src/main/java/io/github/project/openubl/xmlsender/models/jpa/entities/DocumentEntity.java

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,126 @@ public class DocumentEntity extends PanacheEntity {
8282
@Column(name = "custom_id")
8383
public String customId;
8484

85+
public String getRuc() {
86+
return ruc;
87+
}
88+
89+
public void setRuc(String ruc) {
90+
this.ruc = ruc;
91+
}
92+
93+
public String getDocumentID() {
94+
return documentID;
95+
}
96+
97+
public void setDocumentID(String documentID) {
98+
this.documentID = documentID;
99+
}
100+
101+
public DocumentType getDocumentType() {
102+
return documentType;
103+
}
104+
105+
public void setDocumentType(DocumentType documentType) {
106+
this.documentType = documentType;
107+
}
108+
109+
public String getFilenameWithoutExtension() {
110+
return filenameWithoutExtension;
111+
}
112+
113+
public void setFilenameWithoutExtension(String filenameWithoutExtension) {
114+
this.filenameWithoutExtension = filenameWithoutExtension;
115+
}
116+
117+
public String getFileID() {
118+
return fileID;
119+
}
120+
121+
public void setFileID(String fileID) {
122+
this.fileID = fileID;
123+
}
124+
125+
public DeliveryStatusType getDeliveryStatus() {
126+
return deliveryStatus;
127+
}
128+
129+
public void setDeliveryStatus(DeliveryStatusType deliveryStatus) {
130+
this.deliveryStatus = deliveryStatus;
131+
}
132+
133+
public String getDeliveryURL() {
134+
return deliveryURL;
135+
}
136+
137+
public void setDeliveryURL(String deliveryURL) {
138+
this.deliveryURL = deliveryURL;
139+
}
140+
141+
public String getCdrID() {
142+
return cdrID;
143+
}
144+
145+
public void setCdrID(String cdrID) {
146+
this.cdrID = cdrID;
147+
}
148+
149+
public String getSunatUsername() {
150+
return sunatUsername;
151+
}
152+
153+
public void setSunatUsername(String sunatUsername) {
154+
this.sunatUsername = sunatUsername;
155+
}
156+
157+
public String getSunatPassword() {
158+
return sunatPassword;
159+
}
160+
161+
public void setSunatPassword(String sunatPassword) {
162+
this.sunatPassword = sunatPassword;
163+
}
164+
165+
public String getSunatTicket() {
166+
return sunatTicket;
167+
}
168+
169+
public void setSunatTicket(String sunatTicket) {
170+
this.sunatTicket = sunatTicket;
171+
}
172+
173+
public String getSunatStatus() {
174+
return sunatStatus;
175+
}
176+
177+
public void setSunatStatus(String sunatStatus) {
178+
this.sunatStatus = sunatStatus;
179+
}
180+
181+
public Integer getSunatCode() {
182+
return sunatCode;
183+
}
184+
185+
public void setSunatCode(Integer sunatCode) {
186+
this.sunatCode = sunatCode;
187+
}
188+
189+
public String getSunatDescription() {
190+
return sunatDescription;
191+
}
192+
193+
public void setSunatDescription(String sunatDescription) {
194+
this.sunatDescription = sunatDescription;
195+
}
196+
197+
public String getCustomId() {
198+
return customId;
199+
}
200+
201+
public void setCustomId(String customId) {
202+
this.customId = customId;
203+
}
204+
85205
public static final class Builder {
86206
public String ruc;
87207
public String documentID;

api/src/main/java/io/github/project/openubl/xmlsender/ws/WSSunatClient.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,8 @@ public boolean checkDocumentTicket(long documentId) {
119119
try {
120120
ServiceConfig config = new ServiceConfig.Builder()
121121
.url(documentEntity.deliveryURL)
122-
.username(documentEntity.sunatUsername != null
123-
? documentEntity.sunatUsername
124-
: sunatUsername.orElseThrow(() -> new IllegalStateException("Could not find a username for sending to SUNAT"))
125-
)
126-
.password(documentEntity.sunatPassword != null
127-
? documentEntity.sunatPassword
128-
: sunatPassword.orElseThrow(() -> new IllegalStateException("Could not find a username for sending to SUNAT"))
129-
)
122+
.username(documentEntity.sunatUsername != null ? documentEntity.sunatUsername : sunatUsername.orElseThrow(IllegalStateException::new))
123+
.password(documentEntity.sunatPassword != null ? documentEntity.sunatPassword : sunatPassword.orElseThrow(IllegalStateException::new))
130124
.build();
131125
billServiceModel = BillServiceManager.getStatus(documentEntity.sunatTicket, config);
132126
} catch (UnknownWebServiceException e) {
@@ -147,11 +141,11 @@ private void processCDR(BillServiceModel billServiceModel, DocumentEntity docume
147141
}
148142

149143
// Update DB
150-
documentEntity.cdrID = cdrID;
151-
documentEntity.sunatCode = billServiceModel.getCode();
152-
documentEntity.sunatDescription = billServiceModel.getDescription();
153-
documentEntity.sunatStatus = billServiceModel.getStatus().toString();
154-
documentEntity.deliveryStatus = DeliveryStatusType.DELIVERED;
144+
documentEntity.setCdrID(cdrID);
145+
documentEntity.setSunatCode(billServiceModel.getCode());
146+
documentEntity.setSunatDescription(billServiceModel.getDescription());
147+
documentEntity.setSunatStatus(billServiceModel.getStatus().toString());
148+
documentEntity.setDeliveryStatus(DeliveryStatusType.DELIVERED);
155149

156150
documentRepository.persist(documentEntity);
157151

@@ -161,8 +155,8 @@ private void processCDR(BillServiceModel billServiceModel, DocumentEntity docume
161155

162156
private void processTicket(BillServiceModel billServiceModel, DocumentEntity documentEntity) {
163157
// Update DB
164-
documentEntity.deliveryStatus = DeliveryStatusType.SCHEDULED_CHECK_TICKET;
165-
documentEntity.sunatTicket = billServiceModel.getTicket();
158+
documentEntity.setDeliveryStatus(DeliveryStatusType.SCHEDULED_CHECK_TICKET);
159+
documentEntity.setSunatTicket(billServiceModel.getTicket());
166160

167161
documentEntity.persist();
168162

api/src/test/resources/xmls/voided-document_signed.xml

Lines changed: 0 additions & 54 deletions
This file was deleted.

integration-tests/pom.xml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2019 Project OpenUBL, Inc. and/or its affiliates
5+
and other contributors as indicated by the @author tags.
6+
7+
Licensed under the Eclipse Public License - v 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
https://www.eclipse.org/legal/epl-2.0/
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<modelVersion>4.0.0</modelVersion>
24+
<parent>
25+
<groupId>io.github.project-openubl</groupId>
26+
<artifactId>xml-sender</artifactId>
27+
<version>1.0.0-SNAPSHOT</version>
28+
<relativePath>../pom.xml</relativePath>
29+
</parent>
30+
31+
<artifactId>xml-sender-integration-tests</artifactId>
32+
<name>XML Sender :: Integration Tests</name>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>io.github.project-openubl</groupId>
37+
<artifactId>xml-sender-api</artifactId>
38+
</dependency>
39+
40+
<!--Quarkus jdbc-->
41+
<dependency>
42+
<groupId>io.quarkus</groupId>
43+
<artifactId>quarkus-jdbc-h2</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.quarkus</groupId>
47+
<artifactId>quarkus-test-h2</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
51+
<!--Test-->
52+
<dependency>
53+
<groupId>io.quarkus</groupId>
54+
<artifactId>quarkus-junit5</artifactId>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>io.rest-assured</groupId>
59+
<artifactId>rest-assured</artifactId>
60+
<scope>test</scope>
61+
</dependency>
62+
63+
<dependency>
64+
<groupId>org.awaitility</groupId>
65+
<artifactId>awaitility</artifactId>
66+
<version>3.0.0</version>
67+
<scope>test</scope>
68+
</dependency>
69+
</dependencies>
70+
71+
<build>
72+
<plugins>
73+
<plugin>
74+
<groupId>io.quarkus</groupId>
75+
<artifactId>quarkus-maven-plugin</artifactId>
76+
<version>${quarkus.version}</version>
77+
<executions>
78+
<execution>
79+
<goals>
80+
<goal>build</goal>
81+
</goals>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
<plugin>
86+
<artifactId>maven-compiler-plugin</artifactId>
87+
<version>${compiler-plugin.version}</version>
88+
</plugin>
89+
<plugin>
90+
<artifactId>maven-surefire-plugin</artifactId>
91+
<version>${surefire-plugin.version}</version>
92+
<configuration>
93+
<systemProperties>
94+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
95+
</systemProperties>
96+
</configuration>
97+
</plugin>
98+
</plugins>
99+
</build>
100+
</project>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Configuration file
2+
quarkus.artemis.url=tcp://localhost:61616
3+
quarkus.artemis.username=quarkus
4+
quarkus.artemis.password=quarkus
5+
6+
# Quarkus config (applicable when quarkus:dev)
7+
quarkus.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
8+
quarkus.datasource.driver=org.h2.Driver
9+
quarkus.datasource.username=sa
10+
quarkus.datasource.password=sa
11+
quarkus.hibernate-orm.database.generation=drop-and-create
12+
13+
openubl.jms.delay=0
14+
openubl.jms.sendFileQueue=sendFileQueue
15+
openubl.jms.ticketQueue=ticketQueue
16+
openubl.jms.callbackQueue=callbackQueue
17+
18+
openubl.sunat.username=12345678912MODDATOS
19+
openubl.sunat.password=MODDATOS
20+
openubl.sunat.url1=https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService
21+
22+
openubl.storage.type=s3
23+
24+
openubl.storage.filesystem.folder=/home/cferiavi/ubls
25+
26+
openubl.storage.s3.bucket=project-openubl
27+
openubl.storage.s3.access_key_id=BQA2GEXO711FVBVXDWKM
28+
openubl.storage.s3.secret_access_key=uvgz3LCwWM3e400cDkQIH/y1Y4xgU4iV91CwFSPC
29+
openubl.storage.s3.region=us-east-1
30+
openubl.storage.s3.host=http://localhost:9000

0 commit comments

Comments
 (0)