Skip to content

Commit

Permalink
feat: launch exception when not successful
Browse files Browse the repository at this point in the history
  • Loading branch information
mvarlic committed Oct 3, 2024
1 parent 3adbae8 commit 1439001
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import cl.transbank.webpay.exception.InscriptionDeleteException;
import cl.transbank.webpay.exception.InscriptionFinishException;
import cl.transbank.webpay.exception.InscriptionStartException;
import cl.transbank.webpay.exception.TransbankHttpApiException;
import cl.transbank.webpay.oneclick.requests.InscriptionDeleteRequest;
import cl.transbank.webpay.oneclick.requests.InscriptionStartRequest;
import cl.transbank.webpay.oneclick.responses.OneclickMallInscriptionFinishResponse;
Expand Down Expand Up @@ -131,8 +130,6 @@ public boolean delete(String tbkUser, String username)
options
);
return true;
} catch (TransbankHttpApiException e) {
return false;
} catch (TransbankException e) {
throw new InscriptionDeleteException(e);
}
Expand Down
11 changes: 8 additions & 3 deletions src/test/java/webpayplus/OneclickMallDeferredTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ void delete() throws IOException, InscriptionDeleteException {
assertTrue(response);
}
@Test
void deleteNotFound() throws IOException, InscriptionDeleteException {
public void deleteNotFound() throws IOException {
String url = String.format("/%s/inscriptions", apiUrl);
setResponseDeleteError(url, HttpStatusCode.NOT_FOUND_404);
final boolean response = (new Oneclick.MallInscription(option)).delete(tbkUser, username);
assertFalse(response);

try {
new Oneclick.MallInscription(option).delete(tbkUser, username);
fail("Expected InscriptionDeleteException to be thrown");
} catch (InscriptionDeleteException e) {
assertNotNull(e);
}
}
@Test
void authorize() throws IOException, TransactionAuthorizeException {
Expand Down
12 changes: 9 additions & 3 deletions src/test/java/webpayplus/OneclickMallTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ void delete() throws IOException, InscriptionDeleteException {
}

@Test
void deleteNotFound() throws IOException, InscriptionDeleteException {
public void deleteNotFound() throws IOException {
String url = String.format("/%s/inscriptions", apiUrl);
setResponseDeleteError(url, HttpStatusCode.NOT_FOUND_404);
final boolean response = (new Oneclick.MallInscription(option)).delete(tbkUser, username);
assertFalse(response);

try {
new Oneclick.MallInscription(option).delete(tbkUser, username);
fail("Expected InscriptionDeleteException to be thrown");
} catch (InscriptionDeleteException e) {
assertNotNull(e);
}
}

@Test
void authorize() throws IOException, TransactionAuthorizeException {
OneclickMallTransactionStatusResponse expectedResponse = generateStatusResponse();
Expand Down

0 comments on commit 1439001

Please sign in to comment.