Skip to content

Commit

Permalink
Merge pull request #62 from lunasoft/feature/SMARTER-3289
Browse files Browse the repository at this point in the history
SMARTER-3289
  • Loading branch information
JeduardoMT authored May 3, 2022
2 parents 80e4084 + d43db9e commit 55f836d
Show file tree
Hide file tree
Showing 156 changed files with 8,069 additions and 3,972 deletions.
60 changes: 30 additions & 30 deletions README.md

Large diffs are not rendered by default.

24 changes: 17 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>mx.com.sw.services</groupId>
<properties>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
</properties>
<artifactId>SW-JAVA</artifactId>
<version>1.0.6.4${rcsuffix}</version>
<version>1.0.6.5${rcsuffix}</version>
<packaging>jar</packaging>
<scm>
<url>https://github.com/lunasoft/sw-sdk-java</url>
Expand Down Expand Up @@ -58,9 +58,9 @@
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
Expand Down Expand Up @@ -150,12 +150,12 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<version>4.13.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down Expand Up @@ -192,5 +192,15 @@
<artifactId>saaj-impl</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>mx.com.sw.services</groupId>
<artifactId>sw-resources-java</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>
</dependencies>
</project>
3 changes: 1 addition & 2 deletions src/main/java/Utils/Helpers/BuildResponseV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.json.JSONObject;

import Utils.Responses.IResponse;
import Utils.Responses.Stamp.SuccessV1Response;
import Utils.Responses.Stamp.SuccessV2Response;

public class BuildResponseV2 extends ResponseStamp {
Expand All @@ -29,7 +28,7 @@ public IResponse getResponse() {
}
}
else {
return new SuccessV2Response(status, "error", "", "","Error con código "+status+": "+reason.getReasonPhrase(), response);
return new SuccessV2Response(status, "error", "", "","Error con código "+status+": "+reason.getReasonPhrase(), response);
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/Utils/Helpers/BuildResponseV3.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.json.JSONObject;

import Utils.Responses.IResponse;
import Utils.Responses.Stamp.SuccessV2Response;
import Utils.Responses.Stamp.SuccessV3Response;

public class BuildResponseV3 extends ResponseStamp {
Expand All @@ -29,7 +28,7 @@ public IResponse getResponse() {
}
}
else {
return new SuccessV3Response(status, "error", "","Error con código "+status+": "+reason.getReasonPhrase(), response);
return new SuccessV3Response(status, "error", "","Error con código "+status+": "+reason.getReasonPhrase(), response);
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/Utils/Helpers/BuildResponseV4.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.json.JSONObject;

import Utils.Responses.IResponse;
import Utils.Responses.Stamp.SuccessV3Response;
import Utils.Responses.Stamp.SuccessV4Response;

public class BuildResponseV4 extends ResponseStamp {
Expand Down Expand Up @@ -39,7 +38,7 @@ public IResponse getResponse() {
}
}
else {
return new SuccessV4Response(status, "error", "", "", "", "", "", "", "", "", "", "Error con código "+status+": "+reason.getReasonPhrase(), response);
return new SuccessV4Response(status, "error", "", "", "", "", "", "", "", "", "", "Error con código "+status+": "+reason.getReasonPhrase(), response);
}
}
}
3 changes: 1 addition & 2 deletions src/main/java/Utils/Requests/Csd/CsdRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import Utils.Helpers.RequestHelper;
import Utils.Requests.IRequest;
import Utils.Requests.IRequestor;
import Utils.Requests.Csd.CsdOptionsRequest;
import Utils.Responses.IResponse;
import Utils.Responses.Csd.CsdResponse;
import Utils.Responses.Csd.InfoCsd;
Expand All @@ -39,7 +38,7 @@ public IResponse sendRequest(IRequest request) throws GeneralException, AuthExce
try {
if (RequestHelper.stringEmptyOrNull(((CsdOptionsRequest) request).getB64Cer())
|| RequestHelper.stringEmptyOrNull(((CsdOptionsRequest) request).getB64key())) {
return new CsdResponse(400, "error", "El certificado o llave proporcionados vienen vacíos", "");
return new CsdResponse(400, "error", "El certificado o llave proporcionados vienen vacíos", "");
}
JSONObject requestJSON = new JSONObject();
requestJSON.put("type", ((CsdOptionsRequest) request).getCertificateType());
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/Utils/Requests/IRequestor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.xml.soap.SOAPException;

import org.apache.http.client.ClientProtocolException;

import Exceptions.AuthException;
import Exceptions.GeneralException;
import Utils.Requests.IRequest;
import Utils.Responses.IResponse;

public interface IRequestor {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/Utils/Requests/Pdf/PdfRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import Utils.Helpers.RequestHelper;
import Utils.Requests.IRequest;
import Utils.Requests.IRequestor;
import Utils.Requests.Pdf.PdfOptionsRequest;
import Utils.Responses.IResponse;
import Utils.Responses.Pdf.PdfResponse;

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/Utils/Requests/Taxpayer/TaxpayerRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHeader;
Expand All @@ -20,7 +19,6 @@
import Utils.Responses.IResponse;
import Utils.Responses.Taxpayer.TaxpayerData;
import Utils.Responses.Taxpayer.TaxpayerResponse;
import Utils.Requests.Taxpayer.TaxpayerOptionsRequest;

public class TaxpayerRequest {

Expand Down
14 changes: 5 additions & 9 deletions src/test/java/Tests/AcceptReject/SWAcceptRejectServiceTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import Services.Authentication.SWAuthenticationService;
import Utils.Responses.Authentication.SuccessAuthResponse;
import java.io.IOException;

import org.junit.Assert;
import Tests.Utils;
import org.junit.Test;
import Exceptions.AuthException;
import Exceptions.GeneralException;
Expand All @@ -12,7 +14,7 @@ public class SWAuthenticationServiceTest {
@Test
public void testAuth(){
try {
SWAuthenticationService auth = new SWAuthenticationService("demo","123456789","http://services.test.sw.com.mx");
SWAuthenticationService auth = new SWAuthenticationService(Utils.userSW, Utils.passwordSW, Utils.urlSW);
SuccessAuthResponse res = (SuccessAuthResponse) auth.Token();
String expected = "success";
System.out.println(res.token);
Expand All @@ -21,23 +23,22 @@ public void testAuth(){
System.out.println(res.messageDetail);
Assert.assertTrue(expected.equalsIgnoreCase(res.Status));
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
Assert.fail(e.getMessage());
}
}
@Test
public void testBadAuth(){
try {
SWAuthenticationService auth = new SWAuthenticationService("user","password","http://services.test.sw.com.mx");
SuccessAuthResponse res = (SuccessAuthResponse) auth.Token();
SWAuthenticationService auth = new SWAuthenticationService(Utils.userSW, Utils.passwordSW, Utils.urlSW);
auth.Token();
} catch (AuthException e) {
System.out.println(e.getErrorMSG());
System.out.println(e.getHttpStatusCode());
Assert.assertTrue(true);
} catch (GeneralException e) {
Assert.fail();
Assert.fail(e.getMessage());
} catch (IOException e) {
Assert.fail();
Assert.fail(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@


public class SWBalanceAccountServiceTest {
public String token = "T2lYQ0t4L0RHVkR4dHZ5Nkk1VHNEakZ3Y0J4Nk9GODZuRyt4cE1wVm5tbXB3YVZxTHdOdHAwVXY2NTdJb1hkREtXTzE3dk9pMmdMdkFDR2xFWFVPUXpTUm9mTG1ySXdZbFNja3FRa0RlYURqbzdzdlI2UUx1WGJiKzViUWY2dnZGbFloUDJ6RjhFTGF4M1BySnJ4cHF0YjUvbmRyWWpjTkVLN3ppd3RxL0dJPQ.T2lYQ0t4L0RHVkR4dHZ5Nkk1VHNEakZ3Y0J4Nk9GODZuRyt4cE1wVm5tbFlVcU92YUJTZWlHU3pER1kySnlXRTF4alNUS0ZWcUlVS0NhelhqaXdnWTRncklVSWVvZlFZMWNyUjVxYUFxMWFxcStUL1IzdGpHRTJqdS9Zakw2UGRiMTFPRlV3a2kyOWI5WUZHWk85ODJtU0M2UlJEUkFTVXhYTDNKZVdhOXIySE1tUVlFdm1jN3kvRStBQlpLRi9NeWJrd0R3clhpYWJrVUMwV0Mwd3FhUXdpUFF5NW5PN3J5cklMb0FETHlxVFRtRW16UW5ZVjAwUjdCa2g0Yk1iTExCeXJkVDRhMGMxOUZ1YWlIUWRRVC8yalFTNUczZXdvWlF0cSt2UW0waFZKY2gyaW5jeElydXN3clNPUDNvU1J2dm9weHBTSlZYNU9aaGsvalpQMUxrUndzK0dHS2dpTittY1JmR3o2M3NqNkh4MW9KVXMvUHhZYzVLQS9UK2E1SVhEZFJKYWx4ZmlEWDFuSXlqc2ZRYXlUQk1ldlZkU2tEdU10NFVMdHZKUURLblBxakw0SDl5bUxabDFLNmNPbEp6b3Jtd2Q1V2htRHlTdDZ6eTFRdUNnYnVvK2tuVUdhMmwrVWRCZi9rQkU9.7k2gVCGSZKLzJK5Ky3Nr5tKxvGSJhL13Q8W-YhT0uIo";
@Test
public void testBalanceAccountService() throws AuthException, GeneralException, IOException {
SWBalanceAccountService app = new SWBalanceAccountService("demo","123456789",Utils.url_pruebas);
SWBalanceAccountService app = new SWBalanceAccountService(Utils.userSW, Utils.passwordSW, Utils.urlSW);
BalanceAcctResponse response = (BalanceAcctResponse) app.GetBalanceAccount();
System.out.println(response.Status);
System.out.println(response.HttpStatusCode);
Expand All @@ -31,7 +30,7 @@ public void testBalanceAccountService() throws AuthException, GeneralException,
}
@Test
public void testBalanceAccountService_authToken() throws Exception {
SWBalanceAccountService app = new SWBalanceAccountService(token,Utils.url_pruebas);
SWBalanceAccountService app = new SWBalanceAccountService(Utils.tokenSW,Utils.urlSW);
BalanceAcctResponse response = (BalanceAcctResponse) app.GetBalanceAccount();

System.out.println(response.Status);
Expand All @@ -49,7 +48,7 @@ public void testBalanceAccountService_authToken() throws Exception {
@Test
public void testBalanceAccountService_incorrectToken() {
try {
SWBalanceAccountService app = new SWBalanceAccountService("wrong token", Utils.url_pruebas);
SWBalanceAccountService app = new SWBalanceAccountService("wrong token", Utils.urlSW);
BalanceAcctResponse response = (BalanceAcctResponse) app.GetBalanceAccount();
System.out.println(response.Status);
System.out.println(response.HttpStatusCode);
Expand All @@ -74,7 +73,7 @@ public void testBalanceAccountService_incorrectToken() {
public void testBalanceAccountService_emptyUserParams(){
try {
SWBalanceAccountService app = new SWBalanceAccountService("", "", "");
BalanceAcctResponse response = (BalanceAcctResponse) app.GetBalanceAccount();
app.GetBalanceAccount();
}
catch(AuthException e) {
System.out.println(e.getErrorMSG());
Expand Down
Loading

0 comments on commit 55f836d

Please sign in to comment.