use of org.folio.rest.jaxrs.model.Publication in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canUpdateInstanceWithPublicationPeriod.
@Test
public void canUpdateInstanceWithPublicationPeriod() throws Exception {
var entity = smallAngryPlanet(UUID.randomUUID()).mapTo(Instance.class).withPublication(Collections.singletonList(new Publication().withDateOfPublication("1997")));
IndividualResource instance = createInstance(JsonObject.mapFrom(entity));
entity = instance.getJson().mapTo(Instance.class).withPublication(Collections.singletonList(new Publication().withDateOfPublication("2006")));
final IndividualResource updateInstance = updateInstance(JsonObject.mapFrom(entity));
assertEquals(Integer.valueOf(2006), updateInstance.getJson().mapTo(Instance.class).getPublicationPeriod().getStart());
}
use of org.folio.rest.jaxrs.model.Publication in project mod-inventory-storage by folio-org.
the class PublicationPeriodParserTest method shouldReturnNullPeriodForMultiplePublications.
@Test
@Parameters({ "[19uu], null", "hafniae MCMLXX, null", "null, null" })
public void shouldReturnNullPeriodForMultiplePublications(@Nullable String firstDate, @Nullable String lastDate) {
var firstPublication = new Publication().withDateOfPublication(firstDate);
var lastPublication = new Publication().withDateOfPublication(lastDate);
var publicationPeriod = parsePublicationPeriod(List.of(firstPublication, lastPublication));
assertThat(publicationPeriod, nullValue());
}
use of org.folio.rest.jaxrs.model.Publication in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canCreateAnInstance.
@Test
public void canCreateAnInstance() throws InterruptedException, ExecutionException, TimeoutException {
UUID id = UUID.randomUUID();
NatureOfContentTerm journalContentType = createNatureOfContentTerm("journal_test");
NatureOfContentTerm bookContentType = createNatureOfContentTerm("book_test");
String[] natureOfContentIds = Stream.of(journalContentType, bookContentType).map(NatureOfContentTerm::getId).toArray(String[]::new);
var publication = new Publication().withDateOfPublication("2000-2001");
String adminNote = "Administrative note";
JsonObject instanceToCreate = smallAngryPlanet(id);
instanceToCreate.put("natureOfContentTermIds", Arrays.asList(natureOfContentIds));
instanceToCreate.put("publication", new JsonArray().add(JsonObject.mapFrom(publication)));
instanceToCreate.put("administrativeNotes", new JsonArray().add(adminNote));
CompletableFuture<Response> createCompleted = new CompletableFuture<>();
client.post(instancesStorageUrl(""), instanceToCreate, TENANT_ID, json(createCompleted));
Response response = createCompleted.get(5, SECONDS);
assertThat(response.getStatusCode(), is(HttpURLConnection.HTTP_CREATED));
JsonObject instance = response.getJson();
assertThat(instance.getString("id"), is(id.toString()));
assertThat(instance.getString("title"), is("Long Way to a Small Angry Planet"));
assertThat(instance.getBoolean("previouslyHeld"), is(false));
assertThat(instance.getJsonArray("administrativeNotes").contains(adminNote), is(true));
JsonArray identifiers = instance.getJsonArray("identifiers");
assertThat(identifiers.size(), is(1));
assertThat(identifiers, hasItem(identifierMatches(UUID_ISBN.toString(), "9781473619777")));
assertThat(instance.getJsonArray("natureOfContentTermIds"), containsInAnyOrder(natureOfContentIds));
assertThat(instance.getBoolean(DISCOVERY_SUPPRESS), is(false));
Response getResponse = getById(id);
assertThat(getResponse.getStatusCode(), is(HTTP_OK));
JsonObject instanceFromGet = getResponse.getJson();
assertThat(instanceFromGet.getString("title"), is("Long Way to a Small Angry Planet"));
JsonArray identifiersFromGet = instanceFromGet.getJsonArray("identifiers");
assertThat(identifiersFromGet.size(), is(1));
assertThat(identifiersFromGet, hasItem(identifierMatches(UUID_ISBN.toString(), "9781473619777")));
List<String> tags = instanceFromGet.getJsonObject("tags").getJsonArray("tagList").getList();
assertThat(tags.size(), is(1));
assertThat(tags, hasItem(TAG_VALUE));
assertThat(instanceFromGet.getJsonArray("natureOfContentTermIds"), containsInAnyOrder(natureOfContentIds));
assertThat(instanceFromGet.getString(STATUS_UPDATED_DATE_PROPERTY), hasIsoFormat());
assertThat(instanceFromGet.getBoolean(DISCOVERY_SUPPRESS), is(false));
assertCreateEventForInstance(instanceFromGet);
var storedPublicationPeriod = instance.getJsonObject("publicationPeriod").mapTo(PublicationPeriod.class);
assertThat(storedPublicationPeriod.getStart(), is(2000));
assertThat(storedPublicationPeriod.getEnd(), is(2001));
}
use of org.folio.rest.jaxrs.model.Publication in project mod-inventory-storage by folio-org.
the class PublicationPeriodParserTest method shouldReturnNullPeriodForSinglePublication.
@Test
@Parameters({ "[19uu]", "hafniae MCMLXX", "null" })
public void shouldReturnNullPeriodForSinglePublication(@Nullable String dateOfPublication) {
var publication = new Publication().withDateOfPublication(dateOfPublication);
var publicationPeriod = parsePublicationPeriod(List.of(publication));
assertThat(publicationPeriod, nullValue());
}
use of org.folio.rest.jaxrs.model.Publication in project mod-inventory-storage by folio-org.
the class PublicationPeriodParserTest method shouldParseDateOfPublicationForSinglePublication.
@Test
@Parameters({ "1990, 1990, null", "[1990], 1990, null", "©1990, 1990, null", "[1999?], 1999, null", "Cop 1990, 1990, null", "[2003]\\\\, ©2001, 2003, null", "2001\\\\, 2003, 2001, 2003", "2001- 2003, 2001, 2003", "between 2001 and 2003, 2001, 2003" })
public void shouldParseDateOfPublicationForSinglePublication(@Nullable String dateOfPublication, @Nullable Integer start, @Nullable Integer end) {
var publication = new Publication().withDateOfPublication(dateOfPublication);
var publicationPeriod = parsePublicationPeriod(List.of(publication));
assertThat(publicationPeriod.getStart(), is(start));
assertThat(publicationPeriod.getEnd(), is(end));
}
Aggregations