From 86f32a8caf5903f966fdd26443ad033c4a9255b4 Mon Sep 17 00:00:00 2001 From: Edijs Timuls Date: Fri, 6 Dec 2024 16:22:50 +0200 Subject: [PATCH] Add more tests cases to increase coverage. --- .../java/org/folio/ncip/CheckOutItem.java | 39 ++++++++++++++++++- ...-checkout-null-external-reference-type.xml | 32 +++++++++++++++ ...checkout-null-external-reference-value.xml | 33 ++++++++++++++++ ...out-null-request-id-external-reference.xml | 26 +++++++++++++ .../ncip-checkout-null-request-id.xml | 23 +++++++++++ ...checkout-null-request-identifier-value.xml | 26 +++++++++++++ 6 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml create mode 100644 src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml create mode 100644 src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml create mode 100644 src/test/resources/mockdata/ncip-checkout-null-request-id.xml create mode 100644 src/test/resources/mockdata/ncip-checkout-null-request-identifier-value.xml diff --git a/src/test/java/org/folio/ncip/CheckOutItem.java b/src/test/java/org/folio/ncip/CheckOutItem.java index 13c035f..2610ccf 100644 --- a/src/test/java/org/folio/ncip/CheckOutItem.java +++ b/src/test/java/org/folio/ncip/CheckOutItem.java @@ -5,8 +5,7 @@ import java.net.MalformedURLException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; public class CheckOutItem extends TestBase { @@ -18,4 +17,40 @@ public void callCheckOutItem() throws MalformedURLException { assertEquals(200, response.getStatusCode()); assertTrue(body.contains(ITEM_ID)); } + + @Test + public void callCheckOutItemWithoutExternalReference() throws MalformedURLException { + Response response = postData("src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml"); + String body = response.getBody().prettyPrint(); + assertEquals(200, response.getStatusCode()); + assertTrue(body.contains(ITEM_ID)); + } + + @Test + public void callCheckOutItemWithoutExternalReferenceType() throws MalformedURLException { + Response response = postData("src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml"); + String body = response.getBody().prettyPrint(); + assertEquals(200, response.getStatusCode()); + assertTrue(body.contains(ITEM_ID)); + } + + @Test + public void callCheckOutItemEmptyExternalReferenceValue() throws MalformedURLException { + Response response = postData("src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml"); + String body = response.getBody().prettyPrint(); + assertEquals(200, response.getStatusCode()); + assertTrue(body.contains(ITEM_ID)); + } + + @Test + public void callCheckOutItem_GivenNoRequestId() throws MalformedURLException { + Response response = postData("src/test/resources/mockdata/ncip-checkout-null-request-id.xml"); + assertNull(response); + } + + @Test + public void callCheckOutItem_GivenNullRequestIdentifierValue() throws MalformedURLException { + Response response = postData("src/test/resources/mockdata/ncip-checkout-null-request-identifier-value.xml"); + assertNull(response); + } } diff --git a/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml b/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml new file mode 100644 index 0000000..3eac263 --- /dev/null +++ b/src/test/resources/mockdata/ncip-checkout-null-external-reference-type.xml @@ -0,0 +1,32 @@ + + + + + + relais + + + other + + EZBORROW + + + relais + slnp_one_inst_user + + + relais + tl-a11 + + + relais + js-test-0015 + + + + relais + GDFG2343 + + + + \ No newline at end of file diff --git a/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml b/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml new file mode 100644 index 0000000..c7e0a8d --- /dev/null +++ b/src/test/resources/mockdata/ncip-checkout-null-external-reference-value.xml @@ -0,0 +1,33 @@ + + + + + + relais + + + other + + EZBORROW + + + relais + slnp_one_inst_user + + + relais + tl-a11 + + + relais + js-test-0015 + + + + relais + ExternReferenz + + + + + \ No newline at end of file diff --git a/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml b/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml new file mode 100644 index 0000000..2cc6cdc --- /dev/null +++ b/src/test/resources/mockdata/ncip-checkout-null-request-id-external-reference.xml @@ -0,0 +1,26 @@ + + + + + + relais + + + other + + EZBORROW + + + relais + slnp_one_inst_user + + + relais + tl-a11 + + + relais + js-test-0015 + + + \ No newline at end of file diff --git a/src/test/resources/mockdata/ncip-checkout-null-request-id.xml b/src/test/resources/mockdata/ncip-checkout-null-request-id.xml new file mode 100644 index 0000000..5fa1190 --- /dev/null +++ b/src/test/resources/mockdata/ncip-checkout-null-request-id.xml @@ -0,0 +1,23 @@ + + + + + + relais + + + other + + EZBORROW + + + relais + slnp_one_inst_user + + + relais + tl-a11 + + + + \ No newline at end of file diff --git a/src/test/resources/mockdata/ncip-checkout-null-request-identifier-value.xml b/src/test/resources/mockdata/ncip-checkout-null-request-identifier-value.xml new file mode 100644 index 0000000..75b14c8 --- /dev/null +++ b/src/test/resources/mockdata/ncip-checkout-null-request-identifier-value.xml @@ -0,0 +1,26 @@ + + + + + + relais + + + other + + EZBORROW + + + relais + slnp_one_inst_user + + + relais + tl-a12 + + + relais + + + + \ No newline at end of file