use of org.openarchives.oai._2.OAIPMH in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiRecordsWithUntilAndMetadataPrefixMarc21AndResumptionToken.
@ParameterizedTest
@MethodSource("metadataPrefixAndVerbProviderExceptMarc21withHoldings")
void getOaiRecordsWithUntilAndMetadataPrefixMarc21AndResumptionToken(MetadataPrefix prefix, VerbType verb) {
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(METADATA_PREFIX_PARAM, prefix.getName()).param(UNTIL_PARAM, LocalDateTime.now(ZoneOffset.UTC).format(ISO_UTC_DATE_TIME));
OAIPMH oaipmh = verify200WithXml(request, verb);
verifyListResponse(oaipmh, verb, 9);
ResumptionTokenType actualResumptionToken = getResumptionToken(oaipmh, verb);
assertThat(actualResumptionToken, is(notNullValue()));
assertThat(actualResumptionToken.getValue(), is(notNullValue()));
RequestSpecification requestWithResumptionToken = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(RESUMPTION_TOKEN_PARAM, actualResumptionToken.getValue());
OAIPMH oai = verify200WithXml(requestWithResumptionToken, verb);
ResumptionTokenType nextResumptionToken = getResumptionToken(oai, verb);
assertThat(nextResumptionToken, is(notNullValue()));
assertThat(nextResumptionToken.getValue(), is(notNullValue()));
assertThat(nextResumptionToken.getCompleteListSize(), is(equalTo(BigInteger.valueOf(11))));
}
use of org.openarchives.oai._2.OAIPMH in project mod-oai-pmh by folio-org.
the class ResponseHelperTest method shouldBuildResponseWithNotFoundStatusCodeAsDefault.
@Test
void shouldBuildResponseWithNotFoundStatusCodeAsDefault(Vertx vertx, VertxTestContext testContext) {
setupErrorsProcessingSettingWithValue(RESPOND_WITH_ERROR);
vertx.runOnContext(event -> testContext.verify(() -> {
OAIPMHerrorType errorTypeForDefaultStatusCode = new OAIPMHerrorType().withCode(NO_SET_HIERARCHY).withValue(TEST_ERROR_MESSAGE);
OAIPMH oaipmh = responseHelper.buildOaipmhResponseWithErrors(request, errorTypeForDefaultStatusCode);
Response response = responseHelper.buildFailureResponse(oaipmh, request);
verifyResponse(response, HttpStatus.SC_NOT_FOUND);
testContext.completeNow();
}));
}
use of org.openarchives.oai._2.OAIPMH in project mod-oai-pmh by folio-org.
the class ResponseHelperTest method shouldBuildResponseWithServiceUnavailableStatusCode.
@Test
void shouldBuildResponseWithServiceUnavailableStatusCode(Vertx vertx, VertxTestContext testContext) {
setupErrorsProcessingSettingWithValue(RESPOND_WITH_ERROR);
vertx.runOnContext(event -> testContext.verify(() -> {
OAIPMHerrorType serviceUnavailable = new OAIPMHerrorType().withCode(SERVICE_UNAVAILABLE).withValue(TEST_ERROR_MESSAGE);
OAIPMH oaipmh = responseHelper.buildOaipmhResponseWithErrors(request, serviceUnavailable);
Response response = responseHelper.buildFailureResponse(oaipmh, request);
verifyResponse(response, HttpStatus.SC_SERVICE_UNAVAILABLE);
testContext.completeNow();
}));
}
use of org.openarchives.oai._2.OAIPMH in project mod-oai-pmh by folio-org.
the class ResponseHelperTest method shouldBuildOaipmhResponseWithErrorsList.
@Test
void shouldBuildOaipmhResponseWithErrorsList() {
OAIPMH oaipmh = responseHelper.buildOaipmhResponseWithErrors(request, TEST_ERROR_LIST);
assertNotNull(oaipmh.getResponseDate());
assertEquals(oaipmh.getRequest(), request.getOaiRequest());
assertEquals(TEST_ERROR_LIST, oaipmh.getErrors());
}
use of org.openarchives.oai._2.OAIPMH in project mod-oai-pmh by folio-org.
the class ResponseConverterTest method successCase.
@Test
void successCase() {
OAIPMH oaipmh = new OAIPMH().withResponseDate(Instant.EPOCH).withRequest(new RequestType().withValue("oai")).withErrors(new OAIPMHerrorType().withCode(OAIPMHerrorcodeType.BAD_VERB).withValue("error"));
String result = ResponseConverter.getInstance().convertToString(oaipmh);
assertThat(result, not(isEmptyOrNullString()));
// Unmarshal string to OAIPMH and verify that these objects equals
OAIPMH oaipmhFromString = ResponseConverter.getInstance().stringToOaiPmh(result);
assertThat(oaipmh, equalTo(oaipmhFromString));
}
Aggregations