Search in sources :

Example 1 with HrIdFieldServiceImpl

use of org.folio.services.afterprocessing.HrIdFieldServiceImpl in project mod-source-record-manager by folio-org.

the class HrIdFieldServiceTest method shouldNotAdd035FieldIf001FieldNotExists.

@Test
public void shouldNotAdd035FieldIf001FieldNotExists() {
    // given
    String parsedContent = "{\"leader\":\"00115nam  22000731a 4500\",\"fields\":[{\"003\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    String expectedParsedContent = "{\"leader\":\"00115nam  22000731a 4500\",\"fields\":[{\"003\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    ParsedRecord parsedRecord = new ParsedRecord();
    parsedRecord.setContent(parsedContent);
    Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
    // when
    HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
    hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
    // then
    Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
Also used : ExternalIdsHolder(org.folio.rest.jaxrs.model.ExternalIdsHolder) HrIdFieldService(org.folio.services.afterprocessing.HrIdFieldService) HrIdFieldServiceImpl(org.folio.services.afterprocessing.HrIdFieldServiceImpl) Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Test(org.junit.Test)

Example 2 with HrIdFieldServiceImpl

use of org.folio.services.afterprocessing.HrIdFieldServiceImpl in project mod-source-record-manager by folio-org.

the class HrIdFieldServiceTest method shouldNotAdd035FieldIf035FieldExists.

@Test
public void shouldNotAdd035FieldIf035FieldExists() {
    // given
    String parsedContent = "{\"leader\":\"00115nam  22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"003\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"(test)data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    String expectedParsedContent = "{\"leader\":\"00115nam  22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"003\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"(test)data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    ParsedRecord parsedRecord = new ParsedRecord();
    parsedRecord.setContent(parsedContent);
    Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
    // when
    HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
    hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
    // then
    Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
Also used : ExternalIdsHolder(org.folio.rest.jaxrs.model.ExternalIdsHolder) HrIdFieldService(org.folio.services.afterprocessing.HrIdFieldService) HrIdFieldServiceImpl(org.folio.services.afterprocessing.HrIdFieldServiceImpl) Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Test(org.junit.Test)

Example 3 with HrIdFieldServiceImpl

use of org.folio.services.afterprocessing.HrIdFieldServiceImpl in project mod-source-record-manager by folio-org.

the class HrIdFieldServiceTest method shouldAdd035FieldIf001FieldExists.

@Test
public void shouldAdd035FieldIf001FieldExists() {
    // given
    String parsedContent = "{\"leader\":\"00115nam  22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    String expectedParsedContent = "{\"leader\":\"00108nam  22000731a 4500\",\"fields\":[{\"001\":\"in001\"},{\"035\":{\"subfields\":[{\"a\":\"in001\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"507\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}},{\"500\":{\"subfields\":[{\"a\":\"data\"}],\"ind1\":\" \",\"ind2\":\" \"}}]}";
    ParsedRecord parsedRecord = new ParsedRecord();
    parsedRecord.setContent(parsedContent);
    Record record = new Record().withId(UUID.randomUUID().toString()).withParsedRecord(parsedRecord).withGeneration(0).withState(Record.State.ACTUAL).withExternalIdsHolder(new ExternalIdsHolder().withInstanceId("001").withInstanceHrid("in001"));
    // when
    HrIdFieldService hrIdFieldService = new HrIdFieldServiceImpl();
    hrIdFieldService.move001valueTo035Field(Lists.newArrayList(record));
    // then
    Assert.assertEquals(expectedParsedContent, record.getParsedRecord().getContent());
}
Also used : ExternalIdsHolder(org.folio.rest.jaxrs.model.ExternalIdsHolder) HrIdFieldService(org.folio.services.afterprocessing.HrIdFieldService) HrIdFieldServiceImpl(org.folio.services.afterprocessing.HrIdFieldServiceImpl) Record(org.folio.rest.jaxrs.model.Record) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) ParsedRecord(org.folio.rest.jaxrs.model.ParsedRecord) Test(org.junit.Test)

Aggregations

ExternalIdsHolder (org.folio.rest.jaxrs.model.ExternalIdsHolder)3 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)3 Record (org.folio.rest.jaxrs.model.Record)3 HrIdFieldService (org.folio.services.afterprocessing.HrIdFieldService)3 HrIdFieldServiceImpl (org.folio.services.afterprocessing.HrIdFieldServiceImpl)3 Test (org.junit.Test)3