use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPITest method testImportWithUserPreferenceDeliveryIsFalseAndAddressTypeSpecified.
@Test
public void testImportWithUserPreferenceDeliveryIsFalseAndAddressTypeSpecified() 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"));
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 + "defaultDeliveryAddressTypeId 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 testImportWithUserPreferenceDeliveryIsTrueAndInvalidAddressType.
@Test
public void testImportWithUserPreferenceDeliveryIsTrueAndInvalidAddressType() 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(true).withDefaultServicePointId("59646a99-4074-4ee5-bfd4-86f3fc7717z").withDefaultDeliveryAddressTypeId("Returns").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("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 testImportWithUserUpdateAndWrongPreferenceAddressType.
@Test
public void testImportWithUserUpdateAndWrongPreferenceAddressType() throws IOException {
mock.setMockJsonContent("mock_user_update_with_preference_update.json");
List<User> users = new ArrayList<>();
User user = generateUser("89101112", "User", "Update", "58512926-9a29-483b-b801-d36aced855d3");
Address address = new Address().withAddressLine1("Test first line").withCity("Test city").withRegion("Test region").withPostalCode("12345").withAddressTypeId("Returns").withPrimaryAddress(Boolean.FALSE);
List<Address> addresses = new ArrayList<>();
addresses.add(address);
user.getPersonal().setAddresses(addresses);
user.setRequestPreference(new RequestPreference().withHoldShelf(RequestPreference.HoldShelf.TRUE).withDelivery(true).withDefaultServicePointId("59646a99-4074-4ee5-bfd4-86f3fc7717da").withDefaultDeliveryAddressTypeId("Claim").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(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 defaultDeliveryAddressTypeId value does not exist in user addresses collection")).statusCode(200);
}
use of org.folio.rest.jaxrs.model.RequestPreference in project mod-user-import by folio-org.
the class UserImportAPITest method testImportWithUserUpdateAndExistingPreferenceUpdate.
@Test
public void testImportWithUserUpdateAndExistingPreferenceUpdate() throws IOException {
mock.setMockJsonContent("mock_user_update_with_preference_update.json");
List<User> users = new ArrayList<>();
User user = generateUser("89101112", "User", "Update", "58512926-9a29-483b-b801-d36aced855d3");
Address address = new Address().withAddressLine1("Test first line").withCity("Test city").withRegion("Test region").withPostalCode("12345").withAddressTypeId("Returns").withPrimaryAddress(Boolean.FALSE);
List<Address> addresses = new ArrayList<>();
addresses.add(address);
user.getPersonal().setAddresses(addresses);
user.setRequestPreference(new RequestPreference().withHoldShelf(RequestPreference.HoldShelf.TRUE).withDelivery(true).withDefaultServicePointId("59646a99-4074-4ee5-bfd4-86f3fc7717da").withDefaultDeliveryAddressTypeId("Returns").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(1)).body(FAILED_RECORDS, equalTo(0)).body(FAILED_USERS, hasSize(0)).statusCode(200);
}
Aggregations