use of org.openarchives.oai._2.OAIPMHerrorType 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.OAIPMHerrorType 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));
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithWrongMetadataPrefix.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithWrongMetadataPrefix(VerbType verb) {
String metadataPrefix = "abc";
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value()).param(METADATA_PREFIX_PARAM, metadataPrefix);
OAIPMH oaipmh = verifyResponseWithErrors(request, verb, 422, 1);
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(metadataPrefix));
List<OAIPMHerrorType> errors = oaipmh.getErrors();
assertThat(errors.get(0).getCode(), equalTo(CANNOT_DISSEMINATE_FORMAT));
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiListVerbWithoutParams.
@ParameterizedTest
@EnumSource(value = VerbType.class, names = { "LIST_IDENTIFIERS", "LIST_RECORDS" })
void getOaiListVerbWithoutParams(VerbType verb) {
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, verb.value());
List<OAIPMHerrorType> errors = verifyResponseWithErrors(request, verb, 400, 1).getErrors();
OAIPMHerrorType error = errors.get(0);
assertThat(error.getCode(), equalTo(BAD_ARGUMENT));
assertThat(error.getValue(), equalTo(LIST_NO_REQUIRED_PARAM_ERROR));
}
use of org.openarchives.oai._2.OAIPMHerrorType in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method shouldRespondWithBadArgument_whenGetOaiRecordsMarc21WithHoldingsWithInvalidDateRange.
@Test
void shouldRespondWithBadArgument_whenGetOaiRecordsMarc21WithHoldingsWithInvalidDateRange() {
final String currentValue = System.getProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE);
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, "50");
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, LIST_RECORDS.value()).param(FROM_PARAM, INVALID_FROM_PARAM).param(UNTIL_PARAM, INVALID_UNTIL_PARAM).param(METADATA_PREFIX_PARAM, MetadataPrefix.MARC21WITHHOLDINGS.getName());
OAIPMH oaipmh = verifyResponseWithErrors(request, LIST_RECORDS, 400, 1);
assertThat(oaipmh.getRequest().getMetadataPrefix(), equalTo(MetadataPrefix.MARC21WITHHOLDINGS.getName()));
OAIPMHerrorType error = oaipmh.getErrors().get(0);
assertThat(error.getCode(), equalTo(BAD_ARGUMENT));
System.setProperty(REPOSITORY_MAX_RECORDS_PER_RESPONSE, currentValue);
}
Aggregations