Search in sources :

Example 1 with DbTitle

use of org.folio.repository.titles.DbTitle in project mod-kb-ebsco-java by folio-org.

the class EholdingsTitlesTest method shouldUpdateTitleDataOnSecondPut.

@Test
public void shouldUpdateTitleDataOnSecondPut() throws IOException, URISyntaxException {
    String newName = "new name";
    String updatedResponse = "responses/rmapi/resources/get-custom-resource-updated-title-name-response.json";
    putTitle(readFile(updatedResponse), Collections.singletonList(STUB_TAG_VALUE));
    ObjectMapper mapper = new ObjectMapper();
    TitlePutRequest request = mapper.readValue(readFile("requests/kb-ebsco/title/put-title.json"), TitlePutRequest.class);
    request.getData().getAttributes().withName(newName);
    stubFor(get(new UrlPathPattern(new RegexPattern(CUSTOM_TITLE_ENDPOINT), false)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(updatedResponse))));
    putWithOk(EHOLDINGS_TITLES_PATH + "/" + STUB_CUSTOM_TITLE_ID, mapper.writeValueAsString(request), STUB_TOKEN_HEADER);
    List<DbTitle> titles = TitlesTestUtil.getTitles(vertx);
    assertEquals(1, titles.size());
    assertEqualsLong(titles.get(0).getId());
    assertEquals(newName, titles.get(0).getName());
}
Also used : ResponseDefinitionBuilder(com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder) TitlePutRequest(org.folio.rest.jaxrs.model.TitlePutRequest) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) DbTitle(org.folio.repository.titles.DbTitle) Matchers.containsString(org.hamcrest.Matchers.containsString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)1 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)1 DbTitle (org.folio.repository.titles.DbTitle)1 TitlePutRequest (org.folio.rest.jaxrs.model.TitlePutRequest)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Test (org.junit.Test)1