use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method canCreateARequestPreference.
@Test
public void canCreateARequestPreference() {
JsonResponse response = createRequestPreference();
RequestPreference preference = response.getJson().mapTo(RequestPreference.class);
assertThat(response, isCreated());
assertThat(preference.getDefaultServicePointId(), is(SERVICE_POINT_ID));
assertThat(preference.getUserId(), is(USER_ID));
assertThat(preference.getDefaultDeliveryAddressTypeId(), is(ADDRESS_TYPE_ID));
assertThat(preference.getHoldShelf(), is(HOLD_SHELF));
assertThat(preference.getDelivery(), is(DELIVERY));
assertThat(preference.getFulfillment(), is(FULFILLMENT));
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPITest method testImportWithUserPreferenceDeliveryIsFalseAndFulfillmentSpecified.
@Test
public void testImportWithUserPreferenceDeliveryIsFalseAndFulfillmentSpecified() throws IOException {
mock.setMockJsonContent("mock_user_creation_with_new_preference.json");
List<User> users = new ArrayList<>();
User user = generateUser("1234567", "Amy", "Cabble", null);
user.setRequestPreference(new RequestPreference().withHoldShelf(RequestPreference.HoldShelf.TRUE).withDelivery(false).withDefaultServicePointId("59646a99-4074-4ee5-bfd4-86f3fc7717da").withDefaultDeliveryAddressTypeId("71628bf4-1962-4dff-a8f2-11108ab532cc").withFulfillment(RequestPreference.Fulfillment.DELIVERY));
users.add(user);
UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1);
given().header(TENANT_HEADER).header(TOKEN_HEADER).header(new Header(XOkapiHeaders.URL, getOkapiUrl())).header(JSON_CONTENT_TYPE_HEADER).body(collection).post(USER_IMPORT).then().body(MESSAGE, equalTo(UserImportAPIConstants.USERS_WERE_IMPORTED_SUCCESSFULLY)).body(TOTAL_RECORDS, equalTo(1)).body(CREATED_RECORDS, equalTo(0)).body(UPDATED_RECORDS, equalTo(0)).body(FAILED_RECORDS, equalTo(1)).body(FAILED_USERS + "[0]." + EXTERNAL_SYSTEM_ID, equalTo(users.get(0).getExternalSystemId())).body(FAILED_USERS + "[0]." + USERNAME, equalTo(users.get(0).getUsername())).body(FAILED_USERS + "[0]." + USER_ERROR_MESSAGE, containsString(UserImportAPIConstants.FAILED_USER_PREFERENCE_VALIDATION + "fulfillment must be not specified")).statusCode(200);
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPITest method testImportWithUserPreferenceInvalidDefaultServicePoint.
@Test
public void testImportWithUserPreferenceInvalidDefaultServicePoint() throws IOException {
mock.setMockJsonContent("mock_user_creation_with_new_preference.json");
List<User> users = new ArrayList<>();
User user = generateUser("1234567", "Amy", "Cabble", null);
user.setRequestPreference(new RequestPreference().withHoldShelf(RequestPreference.HoldShelf.TRUE).withDelivery(false).withDefaultServicePointId("59646a99-4074-4ee5-bfd4-86f3fc7717d"));
users.add(user);
UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1);
given().header(TENANT_HEADER).header(TOKEN_HEADER).header(new Header(XOkapiHeaders.URL, getOkapiUrl())).header(JSON_CONTENT_TYPE_HEADER).body(collection).post(USER_IMPORT).then().body("errors.parameters", hasSize(1)).statusCode(422);
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPITest method testImportWithUserPreferenceDefaultServicePointNotFound.
@Test
public void testImportWithUserPreferenceDefaultServicePointNotFound() throws IOException {
mock.setMockJsonContent("mock_user_creation_with_new_preference.json");
List<User> users = new ArrayList<>();
User user = generateUser("1234567", "Amy", "Cabble", null);
user.setRequestPreference(new RequestPreference().withHoldShelf(RequestPreference.HoldShelf.TRUE).withDelivery(false).withDefaultServicePointId("00000000-0000-1000-a000-000000000000"));
users.add(user);
UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1);
given().header(TENANT_HEADER).header(TOKEN_HEADER).header(new Header(XOkapiHeaders.URL, getOkapiUrl())).header(JSON_CONTENT_TYPE_HEADER).body(collection).post(USER_IMPORT).then().body(FAILED_USERS + "[0]." + EXTERNAL_SYSTEM_ID, equalTo(users.get(0).getExternalSystemId())).body(FAILED_USERS + "[0]." + USERNAME, equalTo(users.get(0).getUsername())).body(FAILED_USERS + "[0]." + USER_ERROR_MESSAGE, containsString(UserImportAPIConstants.FAILED_USER_PREFERENCE_VALIDATION + "Provided defaultServicePointId value does not exist")).statusCode(200);
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.
the class RequestPreferencesApiTest method createRequestPreference.
private JsonResponse createRequestPreference(String userId) {
CompletableFuture<JsonResponse> createCompleted = new CompletableFuture<>();
RequestPreference preference = constructDefaultPreference(userId);
client.post(requestPreferenceStorageUrl(""), preference, StorageTestSuite.TENANT_ID, ResponseHandler.json(createCompleted));
return getFromFuture(createCompleted);
}
Aggregations