Skip to content

Commit dbc0b4a

Browse files
refactor code and remove client notification on basic method (#5)
1 parent a0c2559 commit dbc0b4a

File tree

17 files changed

+1376
-85
lines changed

17 files changed

+1376
-85
lines changed

.dockerignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*
2-
!distribution/target/*-runner
3-
!distribution/target/*-runner.jar
4-
!distribution/target/lib/*
2+
!api/target/*-runner
3+
!api/target/*-runner.jar
4+
!api/target/lib/*

api/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@
6666
</dependency>
6767
<dependency>
6868
<groupId>io.quarkus</groupId>
69-
<artifactId>quarkus-rest-client</artifactId>
69+
<artifactId>quarkus-artemis-jms</artifactId>
7070
</dependency>
7171
<dependency>
7272
<groupId>io.quarkus</groupId>
73-
<artifactId>quarkus-artemis-jms</artifactId>
73+
<artifactId>quarkus-quartz</artifactId>
7474
</dependency>
7575
<dependency>
7676
<groupId>io.quarkus</groupId>
77-
<artifactId>quarkus-quartz</artifactId>
77+
<artifactId>quarkus-smallrye-health</artifactId>
7878
</dependency>
7979
<dependency>
8080
<groupId>io.quarkus</groupId>

api/src/main/java/io/github/project/openubl/xmlsender/events/BasicEventManager.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,14 @@
1616
*/
1717
package io.github.project.openubl.xmlsender.events;
1818

19-
import io.github.project.openubl.xmlsender.events.jms.SendTicketQueueConsumer;
20-
import io.github.project.openubl.xmlsender.idm.DocumentRepresentation;
2119
import io.github.project.openubl.xmlsender.models.DocumentEvent;
22-
import io.github.project.openubl.xmlsender.models.jpa.DocumentRepository;
23-
import io.github.project.openubl.xmlsender.models.jpa.entities.DocumentEntity;
24-
import io.github.project.openubl.xmlsender.models.utils.EntityToRepresentation;
25-
import io.github.project.openubl.xmlsender.resources.client.CallbackClientService;
2620
import io.github.project.openubl.xmlsender.ws.WSSunatClient;
27-
import org.eclipse.microprofile.rest.client.inject.RestClient;
2821
import org.jboss.logging.Logger;
2922

3023
import javax.enterprise.context.ApplicationScoped;
3124
import javax.enterprise.event.Observes;
3225
import javax.enterprise.event.TransactionPhase;
3326
import javax.inject.Inject;
34-
import javax.transaction.Transactional;
35-
import javax.ws.rs.WebApplicationException;
3627

3728
@ApplicationScoped
3829
public class BasicEventManager {
@@ -42,13 +33,6 @@ public class BasicEventManager {
4233
@Inject
4334
WSSunatClient wsSunatClient;
4435

45-
@Inject
46-
@RestClient
47-
CallbackClientService callbackClientService;
48-
49-
@Inject
50-
DocumentRepository documentRepository;
51-
5236
public void onDocumentCreate(
5337
@Observes(during = TransactionPhase.AFTER_SUCCESS)
5438
@EventProvider(EventProvider.Type.basic) DocumentEvent.Created event
@@ -63,18 +47,11 @@ public void onDocumentRequireCheckTicket(
6347
wsSunatClient.checkDocumentTicket(event.getId());
6448
}
6549

66-
@Transactional
6750
public void onDocumentDelivered(
6851
@Observes(during = TransactionPhase.AFTER_SUCCESS)
6952
@EventProvider(EventProvider.Type.basic) DocumentEvent.Delivered event
7053
) {
71-
DocumentEntity documentEntity = documentRepository.findById(event.getId());
72-
DocumentRepresentation rep = EntityToRepresentation.toRepresentation(documentEntity);
73-
try {
74-
callbackClientService.callback(rep);
75-
} catch (WebApplicationException e) {
76-
LOG.error("Could not send webhook callback, message=" + e.getMessage());
77-
}
54+
LOG.warn("Could not notify client since BASIC even manager does not support it.");
7855
}
7956

8057
}

api/src/main/java/io/github/project/openubl/xmlsender/resources/client/CallbackClientService.java

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

api/src/main/resources/application.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ openubl.event-manager=basic
3636

3737
##Valid for basic event management
3838
openubl.event-manager.basic.retry-delay=43200000
39-
xml-sender-callback-api/mp-rest/url=
40-
xml-sender-callback-api/mp-rest/scope=javax.inject.Singleton
4139

4240
##Valid for JMS event management
4341
openubl.event-manager.jms.delay=500

api/src/test/java/io/github/project/openubl/xmlsender/resources/DocumentsResourceTest.java

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.github.project.openubl.xmlsender.idm.DocumentRepresentation;
2020
import io.github.project.openubl.xmlsender.models.DeliveryStatusType;
21+
import io.github.project.openubl.xmlsender.resources.ApiApplication;
2122
import io.quarkus.test.junit.QuarkusTest;
2223
import io.restassured.http.Header;
2324
import io.restassured.response.Response;
@@ -79,7 +80,8 @@ void withInvalidFileShouldReturnError() {
7980

8081
@Test
8182
void invoice_withSystemCredentials_shouldReturnOK() {
82-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/invoice.xml");
83+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/invoice.xml");
84+
8385
assertNotNull(resource);
8486
File file = new File(resource.getPath());
8587

@@ -106,7 +108,8 @@ void invoice_withSystemCredentials_shouldReturnOK() {
106108

107109
@Test
108110
void invoice_withCustomCredentials_shouldReturnOK() {
109-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/invoice.xml");
111+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/invoice.xml");
112+
110113
assertNotNull(resource);
111114
File file = new File(resource.getPath());
112115

@@ -135,7 +138,8 @@ void invoice_withCustomCredentials_shouldReturnOK() {
135138

136139
@Test
137140
void invoice_downloadFile() throws IOException {
138-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/invoice.xml");
141+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/invoice.xml");
142+
139143
assertNotNull(resource);
140144
File file = new File(resource.getPath());
141145

@@ -163,7 +167,8 @@ void invoice_downloadFile() throws IOException {
163167

164168
@Test
165169
void validInvoice_customCredentials_shouldBeSentToSunat() throws InterruptedException {
166-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/invoice_signed.xml");
170+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/invoice_signed.xml");
171+
167172
assertNotNull(resource);
168173
File file = new File(resource.getPath());
169174

@@ -218,7 +223,8 @@ void validInvoice_customCredentials_shouldBeSentToSunat() throws InterruptedExce
218223

219224
@Test
220225
void invalidInvoice_customCredentials_shouldBeSentToSunat() throws InterruptedException {
221-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/invoice.xml");
226+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/invoice.xml");
227+
222228
assertNotNull(resource);
223229
File file = new File(resource.getPath());
224230

@@ -267,7 +273,8 @@ void invalidInvoice_customCredentials_shouldBeSentToSunat() throws InterruptedEx
267273

268274
@Test
269275
void validCreditNote_customCredentials_shouldBeSentToSunat() throws InterruptedException {
270-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/credit-note_signed.xml");
276+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/credit-note_signed.xml");
277+
271278
assertNotNull(resource);
272279
File file = new File(resource.getPath());
273280

@@ -322,7 +329,8 @@ void validCreditNote_customCredentials_shouldBeSentToSunat() throws InterruptedE
322329

323330
@Test
324331
void invalidCreditNote_customCredentials_shouldBeSentToSunat() throws InterruptedException {
325-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/credit-note.xml");
332+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/credit-note.xml");
333+
326334
assertNotNull(resource);
327335
File file = new File(resource.getPath());
328336

@@ -371,7 +379,8 @@ void invalidCreditNote_customCredentials_shouldBeSentToSunat() throws Interrupte
371379

372380
@Test
373381
void validDebitNote_customCredentials_shouldBeSentToSunat() throws InterruptedException {
374-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/debit-note_signed.xml");
382+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/debit-note_signed.xml");
383+
375384
assertNotNull(resource);
376385
File file = new File(resource.getPath());
377386

@@ -426,7 +435,8 @@ void validDebitNote_customCredentials_shouldBeSentToSunat() throws InterruptedEx
426435

427436
@Test
428437
void invalidDebitNote_customCredentials_shouldBeSentToSunat() throws InterruptedException {
429-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/debit-note.xml");
438+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/debit-note.xml");
439+
430440
assertNotNull(resource);
431441
File file = new File(resource.getPath());
432442

@@ -475,7 +485,8 @@ void invalidDebitNote_customCredentials_shouldBeSentToSunat() throws Interrupted
475485

476486
@Test
477487
void validVoidedDocument_customCredentials_shouldBeSentToSunat() throws InterruptedException {
478-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/voided-document_signed.xml");
488+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/voided-document_signed.xml");
489+
479490
assertNotNull(resource);
480491
File file = new File(resource.getPath());
481492

@@ -530,7 +541,8 @@ void validVoidedDocument_customCredentials_shouldBeSentToSunat() throws Interrup
530541

531542
@Test
532543
void invalidVoidedDocument_customCredentials_shouldBeSentToSunat() throws InterruptedException {
533-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/voided-document.xml");
544+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/voided-document.xml");
545+
534546
assertNotNull(resource);
535547
File file = new File(resource.getPath());
536548

@@ -579,7 +591,8 @@ void invalidVoidedDocument_customCredentials_shouldBeSentToSunat() throws Interr
579591

580592
@Test
581593
void validSummaryDocument_customCredentials_shouldBeSentToSunat() throws InterruptedException {
582-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/summary-document_signed.xml");
594+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/summary-document_signed.xml");
595+
583596
assertNotNull(resource);
584597
File file = new File(resource.getPath());
585598

@@ -634,7 +647,8 @@ void validSummaryDocument_customCredentials_shouldBeSentToSunat() throws Interru
634647

635648
@Test
636649
void invalidSummaryDocument_customCredentials_shouldBeSentToSunat() throws InterruptedException {
637-
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls/summary-document.xml");
650+
URL resource = Thread.currentThread().getContextClassLoader().getResource("xmls2/summary-document.xml");
651+
638652
assertNotNull(resource);
639653
File file = new File(resource.getPath());
640654

0 commit comments

Comments
 (0)