Skip to content

Commit

Permalink
Add more tests cases to increase coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
EddiTim committed Dec 6, 2024
1 parent 6c6a85f commit 86f32a8
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 2 deletions.
39 changes: 37 additions & 2 deletions src/test/java/org/folio/ncip/CheckOutItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd">
<ns1:CheckOutItem>
<ns1:InitiationHeader>
<ns1:FromAgencyId>
<ns1:AgencyId>relais</ns1:AgencyId>
</ns1:FromAgencyId>
<ns1:ToAgencyId>
<ns1:AgencyId>other</ns1:AgencyId>
</ns1:ToAgencyId>
<ns1:ApplicationProfileType>EZBORROW</ns1:ApplicationProfileType>
</ns1:InitiationHeader>
<ns1:UserId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:UserIdentifierValue>slnp_one_inst_user</ns1:UserIdentifierValue>
</ns1:UserId>
<ns1:ItemId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:ItemIdentifierValue>tl-a11</ns1:ItemIdentifierValue>
</ns1:ItemId>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierValue>js-test-0015</ns1:RequestIdentifierValue>
</ns1:RequestId>
<ns1:Ext>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierValue>GDFG2343</ns1:RequestIdentifierValue>
</ns1:RequestId>
</ns1:Ext>
</ns1:CheckOutItem>
</ns1:NCIPMessage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd">
<ns1:CheckOutItem>
<ns1:InitiationHeader>
<ns1:FromAgencyId>
<ns1:AgencyId>relais</ns1:AgencyId>
</ns1:FromAgencyId>
<ns1:ToAgencyId>
<ns1:AgencyId>other</ns1:AgencyId>
</ns1:ToAgencyId>
<ns1:ApplicationProfileType>EZBORROW</ns1:ApplicationProfileType>
</ns1:InitiationHeader>
<ns1:UserId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:UserIdentifierValue>slnp_one_inst_user</ns1:UserIdentifierValue>
</ns1:UserId>
<ns1:ItemId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:ItemIdentifierValue>tl-a11</ns1:ItemIdentifierValue>
</ns1:ItemId>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierValue>js-test-0015</ns1:RequestIdentifierValue>
</ns1:RequestId>
<ns1:Ext>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierType ns1:Scheme="Schema">ExternReferenz</ns1:RequestIdentifierType>
<ns1:RequestIdentifierValue></ns1:RequestIdentifierValue>
</ns1:RequestId>
</ns1:Ext>
</ns1:CheckOutItem>
</ns1:NCIPMessage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd">
<ns1:CheckOutItem>
<ns1:InitiationHeader>
<ns1:FromAgencyId>
<ns1:AgencyId>relais</ns1:AgencyId>
</ns1:FromAgencyId>
<ns1:ToAgencyId>
<ns1:AgencyId>other</ns1:AgencyId>
</ns1:ToAgencyId>
<ns1:ApplicationProfileType>EZBORROW</ns1:ApplicationProfileType>
</ns1:InitiationHeader>
<ns1:UserId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:UserIdentifierValue>slnp_one_inst_user</ns1:UserIdentifierValue>
</ns1:UserId>
<ns1:ItemId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:ItemIdentifierValue>tl-a11</ns1:ItemIdentifierValue>
</ns1:ItemId>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierValue>js-test-0015</ns1:RequestIdentifierValue>
</ns1:RequestId>
</ns1:CheckOutItem>
</ns1:NCIPMessage>
23 changes: 23 additions & 0 deletions src/test/resources/mockdata/ncip-checkout-null-request-id.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd">
<ns1:CheckOutItem>
<ns1:InitiationHeader>
<ns1:FromAgencyId>
<ns1:AgencyId>relais</ns1:AgencyId>
</ns1:FromAgencyId>
<ns1:ToAgencyId>
<ns1:AgencyId>other</ns1:AgencyId>
</ns1:ToAgencyId>
<ns1:ApplicationProfileType>EZBORROW</ns1:ApplicationProfileType>
</ns1:InitiationHeader>
<ns1:UserId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:UserIdentifierValue>slnp_one_inst_user</ns1:UserIdentifierValue>
</ns1:UserId>
<ns1:ItemId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:ItemIdentifierValue>tl-a11</ns1:ItemIdentifierValue>
</ns1:ItemId>
<!-- No RequestId present in this scenario -->
</ns1:CheckOutItem>
</ns1:NCIPMessage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ns1:NCIPMessage xmlns:ns1="http://www.niso.org/2008/ncip" ns1:version="http://www.niso.org/schemas/ncip/v2_0/imp1/xsd/ncip_v2_0.xsd">
<ns1:CheckOutItem>
<ns1:InitiationHeader>
<ns1:FromAgencyId>
<ns1:AgencyId>relais</ns1:AgencyId>
</ns1:FromAgencyId>
<ns1:ToAgencyId>
<ns1:AgencyId>other</ns1:AgencyId>
</ns1:ToAgencyId>
<ns1:ApplicationProfileType>EZBORROW</ns1:ApplicationProfileType>
</ns1:InitiationHeader>
<ns1:UserId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:UserIdentifierValue>slnp_one_inst_user</ns1:UserIdentifierValue>
</ns1:UserId>
<ns1:ItemId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:ItemIdentifierValue>tl-a12</ns1:ItemIdentifierValue>
</ns1:ItemId>
<ns1:RequestId>
<ns1:AgencyId>relais</ns1:AgencyId>
<ns1:RequestIdentifierValue></ns1:RequestIdentifierValue> <!-- Empty identifier -->
</ns1:RequestId>
</ns1:CheckOutItem>
</ns1:NCIPMessage>

0 comments on commit 86f32a8

Please sign in to comment.