Search in sources :

Example 1 with RequestPreference

use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.

the class RequestPreferencesApiTest method cannotUpdateRequestPreferenceWithDuplicateUserId.

@Test
public void cannotUpdateRequestPreferenceWithDuplicateUserId() {
    createRequestPreference(USER_ID);
    RequestPreference secondPreference = createRequestPreference(USER_ID2).getJson().mapTo(RequestPreference.class);
    JsonResponse response = updatePreference(constructDefaultPreference(USER_ID).withId(secondPreference.getId()));
    assertThat(response, isUnprocessableEntity());
    assertThat(response.getJson().toString(), containsString("Request preference for specified user already exists"));
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 2 with RequestPreference

use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.

the class RequestPreferencesApiTest method cannotUpdateRequestPreferenceWithNotExistingId.

@Test
public void cannotUpdateRequestPreferenceWithNotExistingId() {
    RequestPreference preference = constructDefaultPreference(USER_ID).withId(UUID.randomUUID().toString());
    JsonResponse response = updatePreference(preference);
    assertThat(response, isNotFound());
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 3 with RequestPreference

use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.

the class RequestPreferencesApiTest method canUpdateRequestPreference.

@Test
public void canUpdateRequestPreference() {
    RequestPreference preference = createRequestPreference().getJson().mapTo(RequestPreference.class);
    preference.setDelivery(false);
    preference.setDefaultDeliveryAddressTypeId(null);
    JsonResponse response = updatePreference(preference);
    assertThat(response, isNoContent());
    RequestPreference updatedPreference = getPreference(preference.getId()).getJson().mapTo(RequestPreference.class);
    assertPreferenceEquals(preference, updatedPreference);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 4 with RequestPreference

use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.

the class RequestPreferencesApiTest method canGetRequestPreferenceByUserIdUsingQuery.

@Test
public void canGetRequestPreferenceByUserIdUsingQuery() {
    RequestPreference createdPreference = createRequestPreference().getJson().mapTo(RequestPreference.class);
    JsonResponse response = getPreferences("query=userId=" + USER_ID);
    RequestPreferences preferences = response.getJson().mapTo(RequestPreferences.class);
    assertThat(preferences.getTotalRecords(), is(1));
    RequestPreference foundPreference = preferences.getRequestPreferences().get(0);
    assertPreferenceEquals(createdPreference, foundPreference);
}
Also used : RequestPreferences(org.folio.rest.jaxrs.model.RequestPreferences) RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Example 5 with RequestPreference

use of org.folio.rest.jaxrs.model.RequestPreference in project mod-circulation-storage by folio-org.

the class RequestPreferencesApiTest method canGetRequestPreferenceById.

@Test
public void canGetRequestPreferenceById() {
    RequestPreference preference = createRequestPreference().getJson().mapTo(RequestPreference.class);
    RequestPreference responsePreference = getPreference(preference.getId()).getJson().mapTo(RequestPreference.class);
    assertPreferenceEquals(preference, responsePreference);
}
Also used : RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) Test(org.junit.Test)

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