Search in sources :

Example 6 with RequestPreference

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));
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 7 with RequestPreference

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);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 8 with RequestPreference

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);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 9 with RequestPreference

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);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) TestUtils.generateUser(org.folio.TestUtils.generateUser) User(org.folio.rest.jaxrs.model.User) Header(io.restassured.http.Header) ArrayList(java.util.ArrayList) UserdataimportCollection(org.folio.rest.jaxrs.model.UserdataimportCollection) Test(org.junit.Test)

Example 10 with RequestPreference

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);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) CompletableFuture(java.util.concurrent.CompletableFuture) JsonResponse(org.folio.rest.support.JsonResponse)

Aggregations

RequestPreference (org.folio.rest.jaxrs.model.RequestPreference)24 Test (org.junit.Test)20 User (org.folio.rest.jaxrs.model.User)12 Header (io.restassured.http.Header)11 ArrayList (java.util.ArrayList)11 TestUtils.generateUser (org.folio.TestUtils.generateUser)11 UserdataimportCollection (org.folio.rest.jaxrs.model.UserdataimportCollection)11 JsonResponse (org.folio.rest.support.JsonResponse)9 Address (org.folio.rest.jaxrs.model.Address)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 RequestPreferences (org.folio.rest.jaxrs.model.RequestPreferences)2 JsonObject (io.vertx.core.json.JsonObject)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 List (java.util.List)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1