use of org.openarchives.oai._2.VerbType.GET_RECORD in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiGetRecordVerbWithoutMetadataPrefix.
@Test
void getOaiGetRecordVerbWithoutMetadataPrefix(VertxTestContext testContext) {
String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier);
OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 400, 1);
assertThat(oaipmh.getGetRecord(), is(nullValue()));
assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(BAD_ARGUMENT));
testContext.completeNow();
}
use of org.openarchives.oai._2.VerbType.GET_RECORD in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiRecordByIdInvalidIdentifier.
@ParameterizedTest
@EnumSource(MetadataPrefix.class)
void getOaiRecordByIdInvalidIdentifier(MetadataPrefix metadataPrefix) {
RequestSpecification requestSpecification = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, INVALID_IDENTIFIER).param(METADATA_PREFIX_PARAM, metadataPrefix.getName());
String response = verifyWithCodeWithXml(requestSpecification, 400);
// Check that error message is returned
assertThat(response, is(notNullValue()));
// Unmarshal string to OAIPMH and verify required data presents
OAIPMH oaipmh = ResponseConverter.getInstance().stringToOaiPmh(response);
verifyBaseResponse(oaipmh, GET_RECORD);
assertThat(oaipmh.getGetRecord(), is(nullValue()));
assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(BAD_ARGUMENT));
}
use of org.openarchives.oai._2.VerbType.GET_RECORD in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method headerDatestampOfGetRecordVerbShouldCorrespondToGranularitySetting.
@ParameterizedTest
@MethodSource("allMetadataPrefixesAndGranularityTypesProvider")
void headerDatestampOfGetRecordVerbShouldCorrespondToGranularitySetting(MetadataPrefix prefix, GranularityType granularityType) {
String timeGranularity = System.getProperty(REPOSITORY_TIME_GRANULARITY);
System.setProperty(REPOSITORY_TIME_GRANULARITY, granularityType.value());
String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, prefix.getName());
OAIPMH oaipmh = verify200WithXml(request, GET_RECORD);
verifyHeaderDateStamp(oaipmh, GET_RECORD, granularityType.value());
System.setProperty(REPOSITORY_TIME_GRANULARITY, timeGranularity);
}
use of org.openarchives.oai._2.VerbType.GET_RECORD in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiGetRecordVerbWithNonExistingIdentifier.
@ParameterizedTest
@EnumSource(MetadataPrefix.class)
void getOaiGetRecordVerbWithNonExistingIdentifier(MetadataPrefix metadataPrefix) {
String identifier = IDENTIFIER_PREFIX + OkapiMockServer.NON_EXISTING_IDENTIFIER;
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, metadataPrefix.getName());
OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 404, 1);
assertThat(oaipmh.getGetRecord(), is(nullValue()));
assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(ID_DOES_NOT_EXIST));
}
use of org.openarchives.oai._2.VerbType.GET_RECORD in project mod-oai-pmh by folio-org.
the class OaiPmhImplTest method getOaiGetRecordVerbWithWrongMetadataPrefix.
@Test
void getOaiGetRecordVerbWithWrongMetadataPrefix() {
String metadataPrefix = "mark_xml";
String identifier = IDENTIFIER_PREFIX + OkapiMockServer.EXISTING_IDENTIFIER;
RequestSpecification request = createBaseRequest().with().param(VERB_PARAM, GET_RECORD.value()).param(IDENTIFIER_PARAM, identifier).param(METADATA_PREFIX_PARAM, metadataPrefix);
OAIPMH oaipmh = verifyResponseWithErrors(request, GET_RECORD, 422, 1);
assertThat(oaipmh.getGetRecord(), is(nullValue()));
assertThat(oaipmh.getErrors().get(0).getCode(), equalTo(CANNOT_DISSEMINATE_FORMAT));
}
Aggregations