-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIRC-2117 Return empty result when search doesn't find anything #1485
Changes from 5 commits
82758f6
85417bb
99af030
944e756
e1b076a
422ba2c
da41339
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,6 +15,7 @@ | |||||
|
||||||
import org.folio.circulation.support.http.client.Response; | ||||||
import org.junit.jupiter.api.Test; | ||||||
import org.junit.jupiter.api.Assertions; | ||||||
|
||||||
import api.support.APITests; | ||||||
import api.support.builders.SearchInstanceBuilder; | ||||||
|
@@ -77,6 +78,38 @@ void canGetInstanceById() { | |||||
hasJsonPath("tenantId", is(TENANT_ID_UNIVERSITY))))); | ||||||
} | ||||||
|
||||||
@Test | ||||||
void canGetEmptyResult() { | ||||||
IndividualResource instance = instancesFixture.basedUponDunkirk(); | ||||||
UUID instanceId = instance.getId(); | ||||||
|
||||||
// create item in tenant "college" | ||||||
setTempTenantId(TENANT_ID_COLLEGE); | ||||||
IndividualResource collegeLocation = locationsFixture.mainFloor(); | ||||||
IndividualResource collegeHoldings = holdingsFixture.defaultWithHoldings(instanceId); | ||||||
IndividualResource collegeItem = itemsFixture.createItemWithHoldingsAndLocation( | ||||||
collegeHoldings.getId(), collegeLocation.getId()); | ||||||
clearTempTenantId(); | ||||||
|
||||||
// create item in tenant "university" | ||||||
setTempTenantId(TENANT_ID_UNIVERSITY); | ||||||
IndividualResource universityLocation = locationsFixture.thirdFloor(); | ||||||
IndividualResource universityHoldings = holdingsFixture.defaultWithHoldings(instanceId); | ||||||
IndividualResource universityItem = itemsFixture.createItemWithHoldingsAndLocation( | ||||||
universityHoldings.getId(), universityLocation.getId()); | ||||||
clearTempTenantId(); | ||||||
|
||||||
// make sure neither item exists in current tenant | ||||||
assertThat(itemsFixture.getById(collegeItem.getId()).getResponse().getStatusCode(), is(404)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
assertThat(itemsFixture.getById(universityItem.getId()).getResponse().getStatusCode(), is(404)); | ||||||
|
||||||
ResourceClient.forSearchClient().replace(instanceId, new JsonObject()); | ||||||
OleksandrVidinieiev marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
Response response = get(String.format("query=(id==%s)", instanceId), 200); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||||||
JsonObject responseJson = response.getJson(); | ||||||
|
||||||
Assertions.assertTrue(responseJson.isEmpty()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest using the same import for assertions as seen throughout this test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for noticing it, fix it |
||||||
} | ||||||
|
||||||
private Response get(String query, int expectedStatusCode) { | ||||||
return restAssuredClient.get(itemsByInstanceUrl(query), expectedStatusCode, | ||||||
"items-by-instance-request"); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we inline it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this?
UUID instanceId = instancesFixture.basedUponDunkirk().getId();
Since we do not call instance object, we could do like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you use this variable only once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, thanks!