Search in sources :

Example 1 with Address

use of org.folio.rest.jaxrs.model.Address in project mod-user-import by folio-org.

the class UserImportAPITest method testImportUserWithNoPreferencesWithUpdateOnlyPresentFieldAndExistingPreferenceNotDelete.

@Test
public void testImportUserWithNoPreferencesWithUpdateOnlyPresentFieldAndExistingPreferenceNotDelete() throws IOException {
    mock.setMockJsonContent("mock_user_update_with_preference_not_delete.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);
    users.add(user);
    UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1).withUpdateOnlyPresentFields(true);
    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);
}
Also used : TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Address(org.folio.rest.jaxrs.model.Address) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 2 with Address

use of org.folio.rest.jaxrs.model.Address in project mod-user-import by folio-org.

the class UserImportAPITest method testImportWithUserAddressAdd.

@Test
public void testImportWithUserAddressAdd() throws IOException {
    mock.setMockJsonContent("mock_import_with_address_add.json");
    List<User> users = new ArrayList<>();
    User user = generateUser("30313233", "User", "Address", "2cbf64a1-5904-4748-ae77-3d0605e911e7");
    Address address = new Address().withAddressLine1("Test first line").withCity("Test city").withRegion("Test region").withPostalCode("12345").withAddressTypeId("Home").withPrimaryAddress(Boolean.FALSE);
    Address address2 = new Address().withAddressLine1("Test first line2").withCity("Test city2").withRegion("Test region2").withPostalCode("123452").withAddressTypeId("Home2").withPrimaryAddress(Boolean.FALSE);
    List<Address> addresses = new ArrayList<>();
    addresses.add(address);
    addresses.add(address2);
    user.getPersonal().setAddresses(addresses);
    users.add(user);
    UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1).withUpdateOnlyPresentFields(true);
    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);
}
Also used : TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Address(org.folio.rest.jaxrs.model.Address) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 3 with Address

use of org.folio.rest.jaxrs.model.Address in project mod-user-import by folio-org.

the class UserImportAPITest method testImportUserWithNoPreferencesWithoutUpdateOnlyPresentFieldAndExistingPreferenceDelete.

@Test
public void testImportUserWithNoPreferencesWithoutUpdateOnlyPresentFieldAndExistingPreferenceDelete() throws IOException {
    mock.setMockJsonContent("mock_user_update_with_preference_delete.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);
    users.add(user);
    UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1).withUpdateOnlyPresentFields(false);
    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);
}
Also used : TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Address(org.folio.rest.jaxrs.model.Address) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 4 with Address

use of org.folio.rest.jaxrs.model.Address in project mod-user-import by folio-org.

the class UserImportAPITest method testImportWithNewPreferenceCreation.

@Test
public void testImportWithNewPreferenceCreation() throws IOException {
    mock.setMockJsonContent("mock_user_creation_with_new_preference.json");
    List<User> users = new ArrayList<>();
    User user = generateUser("1234567", "Amy", "Cabble", null);
    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(1)).body(UPDATED_RECORDS, equalTo(0)).body(FAILED_RECORDS, equalTo(0)).body(FAILED_USERS, hasSize(0)).statusCode(200);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Address(org.folio.rest.jaxrs.model.Address) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 5 with Address

use of org.folio.rest.jaxrs.model.Address in project mod-user-import by folio-org.

the class UserImportAPITest method testImportWithUserAddressRewrite.

@Test
public void testImportWithUserAddressRewrite() throws IOException {
    mock.setMockJsonContent("mock_import_with_address_rewrite.json");
    List<User> users = new ArrayList<>();
    User user = generateUser("34353637", "User2", "Address2", "da4106eb-ec94-49ce-8019-9cc89281091c");
    Address address = new Address();
    address.setAddressLine1("Test first line");
    address.setCity("Test city");
    address.setRegion("Test region");
    address.setPostalCode("12345");
    address.setAddressTypeId("Home");
    address.setPrimaryAddress(Boolean.TRUE);
    List<Address> addresses = new ArrayList<>();
    addresses.add(address);
    user.getPersonal().setAddresses(addresses);
    users.add(user);
    UserdataimportCollection collection = new UserdataimportCollection().withUsers(users).withTotalRecords(1).withUpdateOnlyPresentFields(false);
    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);
}
Also used : TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Address(org.folio.rest.jaxrs.model.Address) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Aggregations

Address (org.folio.rest.jaxrs.model.Address)10 User (org.folio.rest.jaxrs.model.User)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 Header (io.restassured.http.Header)8 TestUtils.generateUser (org.folio.TestUtils.generateUser)8 UserdataimportCollection (org.folio.rest.jaxrs.model.UserdataimportCollection)8 RequestPreference (org.folio.rest.jaxrs.model.RequestPreference)3 JsonObject (io.vertx.core.json.JsonObject)1 HashMap (java.util.HashMap)1 Personal (org.folio.rest.jaxrs.model.Personal)1