use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canDeleteRequestPreferenceById.
@Test
public void canDeleteRequestPreferenceById() {
RequestPreference preference = createRequestPreference().getJson().mapTo(RequestPreference.class);
JsonResponse response = deletePreference(preference.getId());
assertThat(response, isNoContent());
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canGetRequestPreferences.
@Test
public void canGetRequestPreferences() {
createRequestPreference(USER_ID);
createRequestPreference(USER_ID2);
JsonResponse responseGet = getPreferences("");
List<RequestPreference> preferences = responseGet.getJson().getJsonArray("requestPreferences").stream().map(o -> ((JsonObject) o).mapTo(RequestPreference.class)).collect(Collectors.toList());
assertThat(responseGet.getJson().getInteger("totalRecords"), is(2));
assertThat(preferences, hasItem(hasProperty("userId", Matchers.is(USER_ID))));
assertThat(preferences, hasItem(hasProperty("userId", Matchers.is(USER_ID2))));
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method cannotUpdateRequestPreferenceWithInvalidId.
@Test
public void cannotUpdateRequestPreferenceWithInvalidId() {
RequestPreference preference = constructDefaultPreference(USER_ID).withId("invalid_id");
JsonResponse response = updatePreference(preference);
assertThat(response, isUnprocessableEntity());
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportData method fetchRequestPreferences.
private Map<String, RequestPreference> fetchRequestPreferences(UserdataimportCollection userdataCollection) {
final Map<String, RequestPreference> requestPreferenceMap = new HashMap<>();
for (User user : userdataCollection.getUsers()) {
requestPreferenceMap.put(user.getUsername(), user.getRequestPreference());
user.setRequestPreference(null);
}
return requestPreferenceMap;
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPI method createUserPreference.
private Future<RequestPreference> createUserPreference(User user, UserImportData userImportData, Map<String, String> okapiHeaders) {
RequestPreference requestPreference = userImportData.getRequestPreferences().get(user.getUsername());
if (requestPreference == null) {
return Future.succeededFuture();
}
requestPreference.setUserId(user.getId());
return prefService.validate(requestPreference, userImportData, user).compose(o -> {
udpService.updateUserPreference(requestPreference, userImportData);
return prefService.create(okapiHeaders, requestPreference);
});
}
Aggregations