Search in sources :

Example 1 with ActionProfile

use of org.folio.rest.jaxrs.model.ActionProfile in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldNotPostRecordsToRecordsStorageWhenJobProfileSnapshotContainsUpdateMarcActionProfile.

@Test
public void shouldNotPostRecordsToRecordsStorageWhenJobProfileSnapshotContainsUpdateMarcActionProfile(TestContext testContext) {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    MatchProfile matchProfile = new MatchProfile().withName("match 999ff $s to 999ff $s");
    ActionProfile updateMarcAction = new ActionProfile().withName("update marc-bib").withAction(ActionProfile.Action.UPDATE).withFolioRecord(ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC);
    ProfileSnapshotWrapper profileSnapshotWithUpdateMarcAction = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile).withChildSnapshotWrappers(Collections.singletonList(new ProfileSnapshotWrapper().withContentType(MATCH_PROFILE).withContent(JsonObject.mapFrom(matchProfile).getMap()).withChildSnapshotWrappers(Collections.singletonList(new ProfileSnapshotWrapper().withContentType(ACTION_PROFILE).withContent(JsonObject.mapFrom(updateMarcAction).getMap())))));
    WireMock.stubFor(post(RECORDS_SERVICE_URL).willReturn(created().withTransformers(RequestToResponseTransformer.NAME)));
    WireMock.stubFor(post(new UrlPathPattern(new RegexPattern(PROFILE_SNAPSHOT_URL + "/.*"), true)).willReturn(WireMock.created().withBody(Json.encode(profileSnapshotWithUpdateMarcAction))));
    WireMock.stubFor(get(new UrlPathPattern(new RegexPattern(PROFILE_SNAPSHOT_URL + "/.*"), true)).willReturn(WireMock.ok().withBody(Json.encode(profileSnapshotWithUpdateMarcAction))));
    Async async = testContext.async();
    RestAssured.given().spec(spec).body(new JobProfileInfo().withName("MARC records").withId(DEFAULT_JOB_PROFILE_ID).withDataType(JobProfileInfo.DataType.MARC)).when().put(JOB_EXECUTION_PATH + jobExec.getId() + JOB_PROFILE_PATH).then().statusCode(HttpStatus.SC_OK);
    async.complete();
    async = testContext.async();
    RestAssured.given().spec(spec).body(rawRecordsDto.withId(UUID.randomUUID().toString())).when().post(JOB_EXECUTION_PATH + jobExec.getId() + RECORDS_PATH).then().statusCode(HttpStatus.SC_NO_CONTENT);
    async.complete();
    async = testContext.async();
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARSING_IN_PROGRESS.name())).body("startedDate", notNullValue(Date.class));
    async.complete();
    verify(0, getRequestedFor(urlEqualTo(RECORDS_SERVICE_URL)));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) MatchProfile(org.folio.MatchProfile) JobProfileInfo(org.folio.rest.jaxrs.model.JobProfileInfo) UrlPathPattern(com.github.tomakehurst.wiremock.matching.UrlPathPattern) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Async(io.vertx.ext.unit.Async) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) Date(java.util.Date) ActionProfile(org.folio.rest.jaxrs.model.ActionProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 2 with ActionProfile

use of org.folio.rest.jaxrs.model.ActionProfile in project mod-source-record-manager by folio-org.

the class ChangeEngineServiceImplTest method shouldReturnMarcHoldingsRecordWhenProfileHasUpdateAction.

@Test
public void shouldReturnMarcHoldingsRecordWhenProfileHasUpdateAction() {
    RawRecordsDto rawRecordsDto = getTestRawRecordsDto(MARC_HOLDINGS_REC_VALID);
    JobExecution jobExecution = getTestJobExecution();
    jobExecution.setJobProfileSnapshotWrapper(new ProfileSnapshotWrapper().withChildSnapshotWrappers(List.of(new ProfileSnapshotWrapper().withContentType(ProfileSnapshotWrapper.ContentType.ACTION_PROFILE).withContent(new JsonObject(Json.encode(new ActionProfile().withAction(ActionProfile.Action.UPDATE).withFolioRecord(ActionProfile.FolioRecord.MARC_BIBLIOGRAPHIC))).getMap()))));
    when(marcRecordAnalyzer.process(any())).thenReturn(MarcRecordType.HOLDING);
    when(jobExecutionSourceChunkDao.getById(any(), any())).thenReturn(Future.succeededFuture(Optional.of(new JobExecutionSourceChunk())));
    when(jobExecutionSourceChunkDao.update(any(), any())).thenReturn(Future.succeededFuture(new JobExecutionSourceChunk()));
    when(recordsPublishingService.sendEventsWithRecords(any(), any(), any(), any())).thenReturn(Future.succeededFuture(true));
    Future<List<Record>> serviceFuture = executeWithKafkaMock(rawRecordsDto, jobExecution, Future.succeededFuture(true));
    var actual = serviceFuture.result();
    assertThat(actual, hasSize(1));
    assertThat(actual.get(0).getRecordType(), equalTo(Record.RecordType.MARC_HOLDING));
    assertThat(actual.get(0).getErrorRecord(), nullValue());
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) RawRecordsDto(org.folio.rest.jaxrs.model.RawRecordsDto) JsonObject(io.vertx.core.json.JsonObject) JobExecutionSourceChunk(org.folio.rest.jaxrs.model.JobExecutionSourceChunk) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) ActionProfile(org.folio.rest.jaxrs.model.ActionProfile) Test(org.junit.Test)

Example 3 with ActionProfile

use of org.folio.rest.jaxrs.model.ActionProfile in project mod-source-record-manager by folio-org.

the class ChangeEngineServiceImplTest method shouldReturnMarcAuthorityRecordWhenProfileHasDeleteAction.

@Test
public void shouldReturnMarcAuthorityRecordWhenProfileHasDeleteAction() {
    RawRecordsDto rawRecordsDto = getTestRawRecordsDto(MARC_AUTHORITY_REC_VALID);
    JobExecution jobExecution = getTestJobExecution();
    jobExecution.setJobProfileSnapshotWrapper(new ProfileSnapshotWrapper().withChildSnapshotWrappers(List.of(new ProfileSnapshotWrapper().withContentType(ProfileSnapshotWrapper.ContentType.ACTION_PROFILE).withContent(new JsonObject(Json.encode(new ActionProfile().withAction(ActionProfile.Action.DELETE).withFolioRecord(ActionProfile.FolioRecord.MARC_AUTHORITY))).getMap()))));
    when(marcRecordAnalyzer.process(any())).thenReturn(MarcRecordType.AUTHORITY);
    when(jobExecutionSourceChunkDao.getById(any(), any())).thenReturn(Future.succeededFuture(Optional.of(new JobExecutionSourceChunk())));
    when(jobExecutionSourceChunkDao.update(any(), any())).thenReturn(Future.succeededFuture(new JobExecutionSourceChunk()));
    when(recordsPublishingService.sendEventsWithRecords(any(), any(), any(), any())).thenReturn(Future.succeededFuture(true));
    Future<List<Record>> serviceFuture = executeWithKafkaMock(rawRecordsDto, jobExecution, Future.succeededFuture(true));
    var actual = serviceFuture.result();
    assertThat(actual, hasSize(1));
    assertThat(actual.get(0).getRecordType(), equalTo(Record.RecordType.MARC_AUTHORITY));
    assertThat(actual.get(0).getErrorRecord(), nullValue());
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) RawRecordsDto(org.folio.rest.jaxrs.model.RawRecordsDto) JsonObject(io.vertx.core.json.JsonObject) JobExecutionSourceChunk(org.folio.rest.jaxrs.model.JobExecutionSourceChunk) ArgumentMatchers.anyList(org.mockito.ArgumentMatchers.anyList) List(java.util.List) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) ActionProfile(org.folio.rest.jaxrs.model.ActionProfile) Test(org.junit.Test)

Example 4 with ActionProfile

use of org.folio.rest.jaxrs.model.ActionProfile in project mod-source-record-manager by folio-org.

the class DataImportPayloadContextBuilderImplTest method setUp.

@Before
public void setUp() throws Exception {
    record = new Record();
    JobProfile jobProfile = new JobProfile().withId(UUID.randomUUID().toString()).withName("Create MARC Bibs").withDataType(JobProfile.DataType.MARC);
    ActionProfile actionProfile = new ActionProfile().withId(UUID.randomUUID().toString()).withName("Create MARC Bib").withAction(ActionProfile.Action.CREATE).withFolioRecord(ActionProfile.FolioRecord.INSTANCE);
    profileSnapshotWrapper = new ProfileSnapshotWrapper().withId(UUID.randomUUID().toString()).withProfileId(jobProfile.getId()).withContentType(JOB_PROFILE).withContent(jobProfile).withChildSnapshotWrappers(Collections.singletonList(new ProfileSnapshotWrapper().withProfileId(actionProfile.getId()).withContentType(ACTION_PROFILE).withContent(actionProfile)));
}
Also used : Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) JobProfile(org.folio.rest.jaxrs.model.JobProfile) ActionProfile(org.folio.rest.jaxrs.model.ActionProfile) ProfileSnapshotWrapper(org.folio.rest.jaxrs.model.ProfileSnapshotWrapper) Before(org.junit.Before)

Aggregations

ActionProfile (org.folio.rest.jaxrs.model.ActionProfile)4 ProfileSnapshotWrapper (org.folio.rest.jaxrs.model.ProfileSnapshotWrapper)4 JobExecution (org.folio.rest.jaxrs.model.JobExecution)3 Test (org.junit.Test)3 JsonObject (io.vertx.core.json.JsonObject)2 List (java.util.List)2 JobExecutionSourceChunk (org.folio.rest.jaxrs.model.JobExecutionSourceChunk)2 RawRecordsDto (org.folio.rest.jaxrs.model.RawRecordsDto)2 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)2 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)1 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)1 Async (io.vertx.ext.unit.Async)1 Date (java.util.Date)1 MatchProfile (org.folio.MatchProfile)1 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)1 InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)1 JobProfile (org.folio.rest.jaxrs.model.JobProfile)1 JobProfileInfo (org.folio.rest.jaxrs.model.JobProfileInfo)1 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)1 Record (org.folio.rest.jaxrs.model.Record)1