Skip to content

Commit

Permalink
MODSOURMAN-1203 Fix sonar warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytrokrutii committed Aug 29, 2024
1 parent b514854 commit 3df1fe8
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* @deprecated This class will no longer be used to create test data
*/
@Deprecated
@Deprecated(forRemoval = true)
public class SourceStoragePopulateTestMarcRecordsImpl implements SourceStoragePopulateTestMarcRecords {

private static final Logger LOG = LogManager.getLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,10 @@ private static void update005field(Record targetRecord) {
}
}

private boolean isRecordContainsRequiredField(Record record) {
if (record.getRecordType() == Record.RecordType.MARC_BIB) {
var idsHolder = record.getExternalIdsHolder();
if (Objects.isNull(idsHolder) || StringUtils.isEmpty(getValueFromControlledField(record, TAG_001))) {
private boolean isRecordContainsRequiredField(Record marcRecord) {
if (marcRecord.getRecordType() == Record.RecordType.MARC_BIB) {
var idsHolder = marcRecord.getExternalIdsHolder();
if (Objects.isNull(idsHolder) || StringUtils.isEmpty(getValueFromControlledField(marcRecord, TAG_001))) {
return false;
}
if (StringUtils.isEmpty(idsHolder.getInstanceId()) || StringUtils.isEmpty(idsHolder.getInstanceHrid())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class RecordApiTest extends AbstractRestVerticleTest {

private static RawRecord rawEdifactRecord;
private static ParsedRecord parsedEdifactRecord;
private static ParsedRecord parsedMarcRecordWith001and999ff$s;
private static ParsedRecord parsedMarcRecordWith001and999;

static {
try {
Expand All @@ -77,7 +77,7 @@ public class RecordApiTest extends AbstractRestVerticleTest {
.withContent(new ObjectMapper().readValue(TestUtil.readFileFromPath(RAW_EDIFACT_RECORD_CONTENT_SAMPLE_PATH), String.class));
parsedEdifactRecord = new ParsedRecord()
.withContent(new ObjectMapper().readValue(TestUtil.readFileFromPath(PARSED_EDIFACT_RECORD_CONTENT_SAMPLE_PATH), JsonObject.class).encode());
parsedMarcRecordWith001and999ff$s = new ParsedRecord().withId(FIRST_UUID)
parsedMarcRecordWith001and999 = new ParsedRecord().withId(FIRST_UUID)
.withContent(new JsonObject().put("leader", "01542ccm a2200361 4500")
.put("fields", new JsonArray().add(new JsonObject().put("999", new JsonObject()
.put("subfields",
Expand Down Expand Up @@ -232,7 +232,7 @@ public void shouldReturnAllMarcBibRecordsWithNotEmptyStateOnGetWhenNoQueryIsSpec
.withState(Record.State.OLD)
.withExternalIdsHolder(new ExternalIdsHolder()
.withInstanceId(UUID.randomUUID().toString())
.withInstanceHrid(FIRST_HRID));;
.withInstanceHrid(FIRST_HRID));

postRecords(testContext, record_1, record_2, record_3, record_4, record_6);

Expand Down Expand Up @@ -675,7 +675,7 @@ public void shouldUpdateErrorRecordOnPut(TestContext testContext) {
Async async = testContext.async();
Response createResponse = RestAssured.given()
.spec(spec)
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999ff$s))
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999))
.when()
.post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Expand All @@ -696,7 +696,7 @@ public void shouldSendNotFoundWhenUpdateRecordGenerationForNonExistingRecord(Tes
Async async = testContext.async();
RestAssured.given()
.spec(spec)
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999ff$s))
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999))
.when()
.put(SOURCE_STORAGE_RECORDS_PATH + "/" + record_1.getMatchedId() + "/" + GENERATION)
.then()
Expand All @@ -711,7 +711,7 @@ public void shouldSendBadRequestWhenUpdateRecordGenerationWithDuplicate(TestCont
Async async = testContext.async();
Response createResponse = RestAssured.given()
.spec(spec)
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999ff$s))
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999))
.when()
.post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Expand All @@ -737,7 +737,7 @@ public void shouldUpdateRecordGeneration(TestContext testContext) {
Async async = testContext.async();
Response createResponse = RestAssured.given()
.spec(spec)
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999ff$s))
.body(record_1.withParsedRecord(parsedMarcRecordWith001and999))
.when()
.post(SOURCE_STORAGE_RECORDS_PATH);
assertThat(createResponse.statusCode(), is(HttpStatus.SC_CREATED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public void shouldMatchRecordByMultiple024FieldsWithWildcardsInd() {

@Test
public void shouldNotMatchRecordBy035FieldIfRecordExternalIdIsNull(TestContext context) {
String parsedRecordContent = TestUtil.readFileFromPath(PARSED_MARC_WITH_035_FIELD_SAMPLE_PATH);
String parsedRecordContent = TestUtil.readFileFromPath(PARSED_MARC_AUTHORITY_WITH_999_FIELD_SAMPLE_PATH);
String recordId = UUID.randomUUID().toString();
Record record = new Record()
.withId(recordId)
Expand All @@ -567,9 +567,9 @@ public void shouldNotMatchRecordBy035FieldIfRecordExternalIdIsNull(TestContext c
.spec(spec)
.when()
.body(new RecordMatchingDto()
.withRecordType(RecordMatchingDto.RecordType.MARC_BIB)
.withRecordType(RecordMatchingDto.RecordType.MARC_AUTHORITY)
.withFilters(List.of(new Filter()
.withValues(List.of("(OCoLC)63611770", "1234567"))
.withValues(List.of("(OCoLC)63611770", "nin00009530412"))
.withField("035")
.withIndicator1("")
.withIndicator2("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ public void shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified(TestContex
.withMatchedId(firstMatchedId)
.withOrder(1)
.withState(Record.State.ACTUAL)
.withExternalIdsHolder(new ExternalIdsHolder().withInstanceId(FIRST_UUID).withInstanceHrid(FIRST_HRID));;
.withExternalIdsHolder(new ExternalIdsHolder().withInstanceId(FIRST_UUID).withInstanceHrid(FIRST_HRID));

String secondMathcedId = UUID.randomUUID().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public class SourceStorageStreamApiTest extends AbstractRestVerticleTest {
}
}

private static final ParsedRecord invalidParsedRecord = new ParsedRecord()
.withContent("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.");
private static final ErrorRecord errorRecord = new ErrorRecord()
.withDescription("Oops... something happened")
.withContent("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.");
Expand Down Expand Up @@ -703,7 +701,7 @@ public void shouldReturnSortedSourceRecordsOnGetWhenSortByIsSpecified(TestContex
.withState(Record.State.ACTUAL)
.withExternalIdsHolder(new ExternalIdsHolder()
.withInstanceId(SECOND_UUID)
.withInstanceHrid(FIRST_HRID));;
.withInstanceHrid(FIRST_HRID));

String secondMathcedId = UUID.randomUUID().toString();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class TestMarcRecordsApiTest extends AbstractRestVerticleTest {
private static final String POPULATE_TEST_MARK_RECORDS_PATH = "/source-storage/populate-test-marc-records";

@Test
@Ignore
@Ignore("Deprecated endpoint")
public void shouldReturnNoContentOnPostRecordCollectionPassedInBody() throws IOException {
RawRecord rawRecord = new RawRecord().withContent(
new ObjectMapper().readValue(TestUtil.readFileFromPath(RAW_MARC_RECORD_CONTENT_SAMPLE_PATH), String.class));
Expand All @@ -37,7 +37,7 @@ public void shouldReturnNoContentOnPostRecordCollectionPassedInBody() throws IOE
}

@Test
@Ignore
@Ignore("Deprecated endpoint")
public void shouldReturnUnprocessableEntityOnPostWhenNoRecordCollectionPassedInBody() {
TestMarcRecordsCollection testMarcRecordsCollection = new TestMarcRecordsCollection()
.withRawRecords(Collections.singletonList(new RawRecord()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@
"ind2": " "
}
},
{
"035": {
"ind1": " ",
"ind2": " ",
"subfields": [
{
"a": "nin00009530412"
}
]
}
},
{
"035": {
"ind1": " ",
"ind2": " ",
"subfields": [
{
"a": "12345"
}
]
}
},
{
"100": {
"subfields": [
Expand Down

0 comments on commit 3df1fe8

Please sign in to comment.