Search in sources :

Example 1 with MarcRecordSearchRequest

use of org.folio.rest.jaxrs.model.MarcRecordSearchRequest in project mod-source-record-storage by folio-org.

the class SourceStorageStreamApiTest method shouldReturnEmptyResponseOnSearchMarcRecordIdsWhenInstanceIdIsMissing.

@Test
public void shouldReturnEmptyResponseOnSearchMarcRecordIdsWhenInstanceIdIsMissing(TestContext testContext) {
    // given
    final Async async = testContext.async();
    postSnapshots(testContext, snapshot_2);
    Record marc_bib_record_withoutInstanceId = new Record().withId(SECOND_UUID).withSnapshotId(snapshot_2.getJobExecutionId()).withRecordType(Record.RecordType.MARC_BIB).withRawRecord(rawRecord).withParsedRecord(marcRecord).withMatchedId(SECOND_UUID).withOrder(11).withState(Record.State.ACTUAL);
    postRecords(testContext, marc_bib_record_withoutInstanceId);
    MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
    searchRequest.setFieldsSearchExpression("001.value = '393893'");
    // when
    ExtractableResponse<Response> response = RestAssured.given().spec(spec).body(searchRequest).when().post("/source-storage/stream/marc-record-identifiers").then().extract();
    JsonObject responseBody = new JsonObject(response.body().asString());
    // then
    assertEquals(HttpStatus.SC_OK, response.statusCode());
    assertEquals(0, responseBody.getJsonArray("records").size());
    assertEquals(0, responseBody.getInteger("totalCount").intValue());
    async.complete();
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) Async(io.vertx.ext.unit.Async) MarcRecordSearchRequest(org.folio.rest.jaxrs.model.MarcRecordSearchRequest) JsonObject(io.vertx.core.json.JsonObject) RawRecord(org.folio.rest.jaxrs.model.RawRecord) SourceRecord(org.folio.rest.jaxrs.model.SourceRecord) Record(org.folio.rest.jaxrs.model.Record) ErrorRecord(org.folio.rest.jaxrs.model.ErrorRecord) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Test(org.junit.Test)

Example 2 with MarcRecordSearchRequest

use of org.folio.rest.jaxrs.model.MarcRecordSearchRequest in project mod-source-record-storage by folio-org.

the class SourceStorageStreamApiTest method shouldReturnBadRequestOnSearchMarcRecordIdsWhenFieldsSearchExpressionIsWrong.

@Test
public void shouldReturnBadRequestOnSearchMarcRecordIdsWhenFieldsSearchExpressionIsWrong(TestContext testContext) {
    // given
    final Async async = testContext.async();
    MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
    searchRequest.setFieldsSearchExpression("001.value = '3451991' and 005.value = '20140701')");
    // when
    ExtractableResponse<Response> response = RestAssured.given().spec(spec).body(searchRequest).when().post("/source-storage/stream/marc-record-identifiers").then().extract();
    // then
    assertEquals(HttpStatus.SC_BAD_REQUEST, response.statusCode());
    async.complete();
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) Async(io.vertx.ext.unit.Async) MarcRecordSearchRequest(org.folio.rest.jaxrs.model.MarcRecordSearchRequest) Test(org.junit.Test)

Example 3 with MarcRecordSearchRequest

use of org.folio.rest.jaxrs.model.MarcRecordSearchRequest in project mod-source-record-storage by folio-org.

the class SourceStorageStreamApiTest method shouldReturnEmptyResponseOnSearchMarcRecordIdsWhenNoRecordsPosted.

@Test
public void shouldReturnEmptyResponseOnSearchMarcRecordIdsWhenNoRecordsPosted(TestContext testContext) {
    // given
    final Async async = testContext.async();
    MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
    searchRequest.setFieldsSearchExpression("001.value = '3451991'");
    // when
    ExtractableResponse<Response> response = RestAssured.given().spec(spec).body(searchRequest).when().post("/source-storage/stream/marc-record-identifiers").then().extract();
    JsonObject responseBody = new JsonObject(response.body().asString());
    // then
    assertEquals(HttpStatus.SC_OK, response.statusCode());
    assertEquals(0, responseBody.getJsonArray("records").size());
    assertEquals(0, responseBody.getInteger("totalCount").intValue());
    async.complete();
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) Async(io.vertx.ext.unit.Async) MarcRecordSearchRequest(org.folio.rest.jaxrs.model.MarcRecordSearchRequest) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 4 with MarcRecordSearchRequest

use of org.folio.rest.jaxrs.model.MarcRecordSearchRequest in project mod-source-record-storage by folio-org.

the class SourceStorageStreamApiTest method shouldReturnIdOnSearchMarcRecordIdsWhenSearchByLeaderSearchExpression.

@Test
public void shouldReturnIdOnSearchMarcRecordIdsWhenSearchByLeaderSearchExpression(TestContext testContext) {
    // given
    final Async async = testContext.async();
    postSnapshots(testContext, snapshot_2);
    postRecords(testContext, marc_bib_record_2);
    MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
    searchRequest.setLeaderSearchExpression("p_05 = 'c' and p_06 = 'c' and p_07 = 'm'");
    // when
    ExtractableResponse<Response> response = RestAssured.given().spec(spec).body(searchRequest).when().post("/source-storage/stream/marc-record-identifiers").then().extract();
    JsonObject responseBody = new JsonObject(response.body().asString());
    // then
    assertEquals(HttpStatus.SC_OK, response.statusCode());
    assertEquals(1, responseBody.getJsonArray("records").size());
    assertEquals(1, responseBody.getInteger("totalCount").intValue());
    async.complete();
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) Async(io.vertx.ext.unit.Async) MarcRecordSearchRequest(org.folio.rest.jaxrs.model.MarcRecordSearchRequest) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Example 5 with MarcRecordSearchRequest

use of org.folio.rest.jaxrs.model.MarcRecordSearchRequest in project mod-source-record-storage by folio-org.

the class SourceStorageStreamApiTest method shouldReturnIdOnSearchMarcRecordIdsWhenSearchByFieldsSearchExpression.

@Test
public void shouldReturnIdOnSearchMarcRecordIdsWhenSearchByFieldsSearchExpression(TestContext testContext) {
    // given
    final Async async = testContext.async();
    postSnapshots(testContext, snapshot_2);
    postRecords(testContext, marc_bib_record_2);
    MarcRecordSearchRequest searchRequest = new MarcRecordSearchRequest();
    searchRequest.setFieldsSearchExpression("001.value = '393893' " + "and 005.value ^= '2014110' " + "and 035.ind1 = '#' " + "and 005.03_02 = '41' " + "and 005.date in '20120101-20190101' " + "and 035.value is 'present' " + "and 999.value is 'absent' " + "and 041.g is 'present' " + "and 041.z is 'absent' " + "and 050.ind1 is 'present' " + "and 050.ind2 is 'absent'");
    // when
    ExtractableResponse<Response> response = RestAssured.given().spec(spec).body(searchRequest).when().post("/source-storage/stream/marc-record-identifiers").then().extract();
    JsonObject responseBody = new JsonObject(response.body().asString());
    // then
    assertEquals(HttpStatus.SC_OK, response.statusCode());
    assertEquals(1, responseBody.getJsonArray("records").size());
    assertEquals(1, responseBody.getInteger("totalCount").intValue());
    async.complete();
}
Also used : ExtractableResponse(io.restassured.response.ExtractableResponse) Response(io.restassured.response.Response) Async(io.vertx.ext.unit.Async) MarcRecordSearchRequest(org.folio.rest.jaxrs.model.MarcRecordSearchRequest) JsonObject(io.vertx.core.json.JsonObject) Test(org.junit.Test)

Aggregations

ExtractableResponse (io.restassured.response.ExtractableResponse)17 Response (io.restassured.response.Response)17 Async (io.vertx.ext.unit.Async)17 MarcRecordSearchRequest (org.folio.rest.jaxrs.model.MarcRecordSearchRequest)17 Test (org.junit.Test)17 JsonObject (io.vertx.core.json.JsonObject)15 ErrorRecord (org.folio.rest.jaxrs.model.ErrorRecord)6 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)6 RawRecord (org.folio.rest.jaxrs.model.RawRecord)6 Record (org.folio.rest.jaxrs.model.Record)6 SourceRecord (org.folio.rest.jaxrs.model.SourceRecord)6 AdditionalInfo (org.folio.rest.jaxrs.model.AdditionalInfo)2