Search in sources :

Example 1 with RequestPreferences

use of org.folio.rest.jaxrs.model.RequestPreferences 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 2 with RequestPreferences

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

the class RequestPreferencesApiTest method canGetRequestPreferences.

@Test
public void canGetRequestPreferences() {
    createRequestPreference(USER_ID);
    createRequestPreference(USER_ID2);
    JsonResponse responseGet = getPreferences("");
    List<RequestPreference> preferences = responseGet.getJson().getJsonArray("requestPreferences").stream().map(o -> ((JsonObject) o).mapTo(RequestPreference.class)).collect(Collectors.toList());
    assertThat(responseGet.getJson().getInteger("totalRecords"), is(2));
    assertThat(preferences, hasItem(hasProperty("userId", Matchers.is(USER_ID))));
    assertThat(preferences, hasItem(hasProperty("userId", Matchers.is(USER_ID2))));
}
Also used : ResponseHandler(org.folio.rest.support.ResponseHandler) JsonResponse(org.folio.rest.support.JsonResponse) RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) URL(java.net.URL) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Matchers.hasProperty(org.hamcrest.Matchers.hasProperty) Is.is(org.hamcrest.core.Is.is) JsonObject(io.vertx.core.json.JsonObject) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HttpResponseStatusCodeMatchers.isNotFound(org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isNotFound) Before(org.junit.Before) MalformedURLException(java.net.MalformedURLException) HttpResponseStatusCodeMatchers.isCreated(org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isCreated) HttpResponseStatusCodeMatchers.isUnprocessableEntity(org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isUnprocessableEntity) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) UUID(java.util.UUID) ApiTests(org.folio.rest.support.ApiTests) Collectors(java.util.stream.Collectors) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) RequestPreferences(org.folio.rest.jaxrs.model.RequestPreferences) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) HttpResponseStatusCodeMatchers.isNoContent(org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isNoContent) Matchers.containsString(org.hamcrest.Matchers.containsString) RequestPreference(org.folio.rest.jaxrs.model.RequestPreference) JsonObject(io.vertx.core.json.JsonObject) JsonResponse(org.folio.rest.support.JsonResponse) Test(org.junit.Test)

Aggregations

RequestPreference (org.folio.rest.jaxrs.model.RequestPreference)2 RequestPreferences (org.folio.rest.jaxrs.model.RequestPreferences)2 JsonResponse (org.folio.rest.support.JsonResponse)2 Test (org.junit.Test)2 JsonObject (io.vertx.core.json.JsonObject)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 List (java.util.List)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Collectors (java.util.stream.Collectors)1 ApiTests (org.folio.rest.support.ApiTests)1 ResponseHandler (org.folio.rest.support.ResponseHandler)1 HttpResponseStatusCodeMatchers.isCreated (org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isCreated)1 HttpResponseStatusCodeMatchers.isNoContent (org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isNoContent)1 HttpResponseStatusCodeMatchers.isNotFound (org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isNotFound)1 HttpResponseStatusCodeMatchers.isUnprocessableEntity (org.folio.rest.support.matchers.HttpResponseStatusCodeMatchers.isUnprocessableEntity)1