-
Notifications
You must be signed in to change notification settings - Fork 1
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
MCBFF-38: Update hardcoded effective location during checkin #47
base: master
Are you sure you want to change the base?
Conversation
f662700
to
131db36
Compare
var request = new CheckInRequest() | ||
.itemBarcode("test_barcode") | ||
.checkInDate(new Date()) | ||
.servicePointId(randomUUID()); | ||
|
||
givenCirculationCheckinSucceed(request); | ||
|
||
var checkinItem = new Item() | ||
.id("itemId") | ||
.copyNumber("copyNumber") | ||
.effectiveLocationId( "effectiveLocationId"); | ||
|
||
givenSearchInstanceReturnsItem(TENANT_ID_COLLEGE, checkinItem); | ||
|
||
givenCurrentTenantIsConsortium(); |
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.
var request = new CheckInRequest() | |
.itemBarcode("test_barcode") | |
.checkInDate(new Date()) | |
.servicePointId(randomUUID()); | |
givenCirculationCheckinSucceed(request); | |
var checkinItem = new Item() | |
.id("itemId") | |
.copyNumber("copyNumber") | |
.effectiveLocationId( "effectiveLocationId"); | |
givenSearchInstanceReturnsItem(TENANT_ID_COLLEGE, checkinItem); | |
givenCurrentTenantIsConsortium(); | |
var request = new CheckInRequest() | |
.itemBarcode("test_barcode") | |
.checkInDate(new Date()) | |
.servicePointId(randomUUID()); | |
givenCirculationCheckinSucceed(request); | |
var checkinItem = new Item() | |
.id("itemId") | |
.copyNumber("copyNumber") | |
.effectiveLocationId( "effectiveLocationId"); | |
givenSearchInstanceReturnsItem(TENANT_ID_COLLEGE, checkinItem); | |
givenCurrentTenantIsConsortium(); |
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.
Aren't empty lines OK? I see them in other places and in my opinion they are improving readability.
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.
They enhance readability by splitting certain logic blocks of code, but I don't think it’s necessary to place them after every line...
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.
fixed
var request = new CheckInRequest() | ||
.itemBarcode("test_barcode") | ||
.checkInDate(new Date()) | ||
.servicePointId(randomUUID()); | ||
|
||
givenCirculationCheckinSucceed(request); | ||
|
||
var searchResponse = new SearchInstances().instances(List.of()); | ||
wireMockServer.stubFor(WireMock.get(urlMatching("/search/instances.*")) | ||
.willReturn(jsonResponse(searchResponse, SC_OK))); | ||
|
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.
var request = new CheckInRequest() | |
.itemBarcode("test_barcode") | |
.checkInDate(new Date()) | |
.servicePointId(randomUUID()); | |
givenCirculationCheckinSucceed(request); | |
var searchResponse = new SearchInstances().instances(List.of()); | |
wireMockServer.stubFor(WireMock.get(urlMatching("/search/instances.*")) | |
.willReturn(jsonResponse(searchResponse, SC_OK))); | |
var request = new CheckInRequest() | |
.itemBarcode("test_barcode") | |
.checkInDate(new Date()) | |
.servicePointId(randomUUID()); | |
givenCirculationCheckinSucceed(request); | |
var searchResponse = new SearchInstances().instances(List.of()); | |
wireMockServer.stubFor(WireMock.get(urlMatching("/search/instances.*")) | |
.willReturn(jsonResponse(searchResponse, SC_OK))); |
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.
done
log.info("getEffectiveLocationServicePoint: itemId {}", itemId); | ||
var instance = searchService.findInstanceByItemId(itemId); | ||
if (instance == null) { | ||
log.info("getEffectiveLocationServicePoint: instance not found"); |
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.
log.info("getEffectiveLocationServicePoint: instance not found"); | |
log.warn("getEffectiveLocationServicePoint: instance not found"); |
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.
fixed
public SearchInstance findInstanceByItemId(String itemId) { | ||
log.info("findInstanceByItemId:: itemId {}", itemId); | ||
String query = String.format("items.id==%s&expandAll=true", itemId); | ||
SearchInstances searchResult = searchClient.findInstances(query, true); |
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.
SearchInstances searchResult = searchClient.findInstances(query, true); | |
SearchInstances searchInstances = searchClient.findInstances(query, true); |
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
@@ -150,7 +150,11 @@ | |||
"circulation-bff.loans.check-in-by-barcode.execute" | |||
], | |||
"modulePermissions": [ | |||
"circulation.check-in-by-barcode.post" | |||
"circulation.check-in-by-barcode.post", | |||
"user-tenants.collection.get", |
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.
please add the same for item
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.
Why we need user-tenants.item.get
?
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.
There's a rule that if we add a permission for an item, we need to add a similar one for the collection, and vice versa
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.
Could not find user-tenants.item.get
anywhere in folio-org. Does it exists?
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 are right, it exists only for consortia.user-tenants.item.get, so ignore it then
"inventory-storage.items.item.get", | ||
"inventory-storage.service-points.item.get" |
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.
please add the same permissions for collections
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.
done
public String getCurrentTenant() { | ||
UserTenant firstUserTenant = getFirstUserTenant(); | ||
if (firstUserTenant == null) { | ||
log.info("getCurrentTenant:: failed to fetch user tenants"); |
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.
log.info("getCurrentTenant:: failed to fetch user tenants"); | |
log.warn("getCurrentTenant:: failed to fetch user tenants"); |
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.
Good point. But then we need to change this for similar lines in this file right?
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.
It appears that the absence of the first user-tenant is unexpected behavior, and should be logged with warning level. This approach should be applied to all similar cases
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.
fixed duplicate logging in the class
d6e1f53
to
ae4a787
Compare
when(searchClient.findInstances(query, true)) | ||
.thenReturn(mockSearchResponse); |
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.
when(searchClient.findInstances(query, true)) | |
.thenReturn(mockSearchResponse); | |
when(searchClient.findInstances(query, true)).thenReturn(mockSearchResponse); |
SearchInstance response = searchService.findInstanceByItemId(itemId); | ||
assertEquals(response, instance); |
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.
SearchInstance response = searchService.findInstanceByItemId(itemId); | |
assertEquals(response, instance); | |
assertEquals(searchService.findInstanceByItemId(itemId), instance); |
Quality Gate passedIssues Measures |
Purpose
https://folio-org.atlassian.net/browse/MCBFF-38
Approach
Obtain proper effective location based on item's effectiveLocationId and tenant and update required fields in response.
TODOS and Open Questions
Learning