Search in sources :

Example 1 with TitleCollectionItem

use of org.folio.rest.jaxrs.model.TitleCollectionItem in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesTest method shouldReturnEmptyTitlesOnSearchByAccessTypesThatIsNotExist.

@Test
public void shouldReturnEmptyTitlesOnSearchByAccessTypesThatIsNotExist() throws IOException, URISyntaxException {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID_2, RESOURCE, accessTypes.get(1).getId(), vertx);
    mockGetTitles();
    String resourcePath = EHOLDINGS_TITLES_PATH + "?filter[access-type]=Not Exist";
    TitleCollection titleCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(TitleCollection.class);
    List<TitleCollectionItem> titles = titleCollection.getData();
    assertThat(titles, hasSize(0));
    assertEquals(0, (int) titleCollection.getMeta().getTotalResults());
}
Also used : TitleCollectionItem(org.folio.rest.jaxrs.model.TitleCollectionItem) Matchers.containsString(org.hamcrest.Matchers.containsString) AccessType(org.folio.rest.jaxrs.model.AccessType) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) Test(org.junit.Test)

Example 2 with TitleCollectionItem

use of org.folio.rest.jaxrs.model.TitleCollectionItem in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesTest method shouldReturnTitlesOnSearchByAccessTypes.

@Test
public void shouldReturnTitlesOnSearchByAccessTypes() throws IOException, URISyntaxException {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID_2, RESOURCE, accessTypes.get(0).getId(), vertx);
    mockGetTitles();
    String resourcePath = EHOLDINGS_TITLES_PATH + "?filter[access-type]=" + STUB_ACCESS_TYPE_NAME;
    TitleCollection titleCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(TitleCollection.class);
    List<TitleCollectionItem> titles = titleCollection.getData();
    assertThat(titles, hasSize(2));
    assertEquals(2, (int) titleCollection.getMeta().getTotalResults());
    assertThat(titles, everyItem(hasProperty("id", anyOf(equalTo(STUB_MANAGED_TITLE_ID), equalTo(STUB_MANAGED_TITLE_ID_2)))));
}
Also used : TitleCollectionItem(org.folio.rest.jaxrs.model.TitleCollectionItem) Matchers.containsString(org.hamcrest.Matchers.containsString) AccessType(org.folio.rest.jaxrs.model.AccessType) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) Test(org.junit.Test)

Example 3 with TitleCollectionItem

use of org.folio.rest.jaxrs.model.TitleCollectionItem in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesTest method shouldReturnTitleOnSearchByAccessTypesWithPagination.

@Test
public void shouldReturnTitleOnSearchByAccessTypesWithPagination() throws IOException, URISyntaxException {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID_2, RESOURCE, accessTypes.get(1).getId(), vertx);
    mockGetTitles();
    String resourcePath = EHOLDINGS_TITLES_PATH + "?page=2&count=1&filter[access-type]=" + STUB_ACCESS_TYPE_NAME + "&filter[access-type]=" + STUB_ACCESS_TYPE_NAME_2;
    TitleCollection titleCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(TitleCollection.class);
    List<TitleCollectionItem> titles = titleCollection.getData();
    assertThat(titles, hasSize(1));
    assertEquals(2, (int) titleCollection.getMeta().getTotalResults());
    assertThat(titles, everyItem(hasProperty("id", equalTo(STUB_MANAGED_TITLE_ID))));
}
Also used : TitleCollectionItem(org.folio.rest.jaxrs.model.TitleCollectionItem) Matchers.containsString(org.hamcrest.Matchers.containsString) AccessType(org.folio.rest.jaxrs.model.AccessType) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) Test(org.junit.Test)

Example 4 with TitleCollectionItem

use of org.folio.rest.jaxrs.model.TitleCollectionItem in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesTest method shouldReturnTitlesWithResourcesOnSearchByAccessTypes.

@Test
public void shouldReturnTitlesWithResourcesOnSearchByAccessTypes() throws IOException, URISyntaxException {
    List<AccessType> accessTypes = insertAccessTypes(testData(configuration.getId()), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID, RESOURCE, accessTypes.get(0).getId(), vertx);
    insertAccessTypeMapping(STUB_MANAGED_RESOURCE_ID_2, RESOURCE, accessTypes.get(0).getId(), vertx);
    mockGetTitles();
    String resourcePath = EHOLDINGS_TITLES_PATH + "?filter[access-type]=" + STUB_ACCESS_TYPE_NAME + "&include=resources";
    TitleCollection titleCollection = getWithOk(resourcePath, STUB_TOKEN_HEADER).as(TitleCollection.class);
    List<TitleCollectionItem> titles = titleCollection.getData();
    assertThat(titles, hasSize(2));
    assertEquals(2, (int) titleCollection.getMeta().getTotalResults());
    assertThat(titles, everyItem(hasProperty("id", anyOf(equalTo(STUB_MANAGED_TITLE_ID), equalTo(STUB_MANAGED_TITLE_ID_2)))));
    assertThat(titles, everyItem(hasProperty("included", not(empty()))));
}
Also used : TitleCollectionItem(org.folio.rest.jaxrs.model.TitleCollectionItem) Matchers.containsString(org.hamcrest.Matchers.containsString) AccessType(org.folio.rest.jaxrs.model.AccessType) TitleCollection(org.folio.rest.jaxrs.model.TitleCollection) Test(org.junit.Test)

Aggregations

AccessType (org.folio.rest.jaxrs.model.AccessType)4 TitleCollection (org.folio.rest.jaxrs.model.TitleCollection)4 TitleCollectionItem (org.folio.rest.jaxrs.model.TitleCollectionItem)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 Test (org.junit.Test)4