Skip to content

Commit 5393d95

Browse files
fix(QTDI-1856): sonar
1 parent c0085ef commit 5393d95

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

component-studio/component-runtime-di/src/test/java/org/talend/sdk/component/runtime/di/record/DiRowStructVisitorTest.java

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ void visit() {
145145
rowStruct.emptyDocument = new Document();
146146

147147
final DiRowStructVisitor visitor = new DiRowStructVisitor();
148-
final Record record = visitor.get(rowStruct, factory);
149-
final Schema schema = record.getSchema();
148+
final Record convertedRecord = visitor.get(rowStruct, factory);
149+
final Schema schema = convertedRecord.getSchema();
150150
// should have 3 excluded fields
151151
assertEquals(58, schema.getEntries().size());
152152

@@ -198,66 +198,66 @@ void visit() {
198198
assertEquals("yyyy-MM-dd", schema.getEntry("dynStringDate").getProp(PATTERN));
199199
assertEquals(StudioTypes.DOCUMENT, schema.getEntry("dynDocument").getProp(STUDIO_TYPE));
200200
// asserts Record
201-
assertEquals(":testing:", record.getString("id"));
202-
assertEquals(NAME, record.getString("name"));
203-
assertEquals(SHORT, record.getInt("shortP"));
204-
assertEquals(SHORT, record.getInt("shortC"));
205-
assertEquals(INT, record.getInt("intP"));
206-
assertEquals(INT, record.getInt("intC"));
207-
assertEquals(LONG, record.getLong("longP"));
208-
assertEquals(LONG, record.getLong("longC"));
209-
assertEquals(FLOAT, record.getFloat("floatP"));
210-
assertEquals(FLOAT, record.getFloat("floatC"));
211-
assertEquals(DOUBLE, record.getDouble("doubleP"));
212-
assertEquals(DOUBLE, record.getDouble("doubleC"));
213-
assertEquals(DATE.toInstant(), record.getDateTime("date0").toInstant());
214-
assertNull(record.getDateTime("date1"));
215-
assertEquals(ZONED_DATE_TIME, record.getDateTime("date2"));
216-
assertEquals(1946, record.getDateTime("date2").getYear());
217-
assertEquals(INSTANT, record.getInstant("date4"));
218-
assertEquals(BIGDEC.doubleValue(), new BigDecimal(record.getString("bigDecimal0")).doubleValue());
219-
assertEquals(BIGDEC.toString(), record.getString("bigDecimal0"));
220-
assertFalse(record.getBoolean("bool0"));
221-
assertTrue(record.getBoolean("bool1"));
222-
assertArrayEquals(BYTES0, record.getBytes("bytes0"));
223-
assertArrayEquals(BYTES0, record.getBytes("dynBytes"));
224-
assertArrayEquals(BYTES0, record.getBytes("dynBytesArray"));
225-
assertArrayEquals(BYTES0, record.getBytes("dynBytesBuffer"));
226-
assertArrayEquals(String.valueOf(BYTES0).getBytes(), record.getBytes("dynBytesWString"));
227-
assertEquals(BIGDEC.toString(), record.getString("dynBigDecimal"));
228-
assertEquals(BIGDEC, new BigDecimal(record.getString("dynBigDecimal")));
229-
assertEquals(DOCUMENT.toString(), record.getString("dynDocument"));
230-
assertEquals(rowStruct.object0, record.get(Object.class, "object0"));
231-
assertTrue(record.getBoolean("hAshcOdEdIrtY"));
232-
assertEquals(NAME, record.getString("h"));
201+
assertEquals(":testing:", convertedRecord.getString("id"));
202+
assertEquals(NAME, convertedRecord.getString("name"));
203+
assertEquals(SHORT, convertedRecord.getInt("shortP"));
204+
assertEquals(SHORT, convertedRecord.getInt("shortC"));
205+
assertEquals(INT, convertedRecord.getInt("intP"));
206+
assertEquals(INT, convertedRecord.getInt("intC"));
207+
assertEquals(LONG, convertedRecord.getLong("longP"));
208+
assertEquals(LONG, convertedRecord.getLong("longC"));
209+
assertEquals(FLOAT, convertedRecord.getFloat("floatP"));
210+
assertEquals(FLOAT, convertedRecord.getFloat("floatC"));
211+
assertEquals(DOUBLE, convertedRecord.getDouble("doubleP"));
212+
assertEquals(DOUBLE, convertedRecord.getDouble("doubleC"));
213+
assertEquals(DATE.toInstant(), convertedRecord.getDateTime("date0").toInstant());
214+
assertNull(convertedRecord.getDateTime("date1"));
215+
assertEquals(ZONED_DATE_TIME, convertedRecord.getDateTime("date2"));
216+
assertEquals(1946, convertedRecord.getDateTime("date2").getYear());
217+
assertEquals(INSTANT, convertedRecord.getInstant("date4"));
218+
assertEquals(BIGDEC.doubleValue(), new BigDecimal(convertedRecord.getString("bigDecimal0")).doubleValue());
219+
assertEquals(BIGDEC.toString(), convertedRecord.getString("bigDecimal0"));
220+
assertFalse(convertedRecord.getBoolean("bool0"));
221+
assertTrue(convertedRecord.getBoolean("bool1"));
222+
assertArrayEquals(BYTES0, convertedRecord.getBytes("bytes0"));
223+
assertArrayEquals(BYTES0, convertedRecord.getBytes("dynBytes"));
224+
assertArrayEquals(BYTES0, convertedRecord.getBytes("dynBytesArray"));
225+
assertArrayEquals(BYTES0, convertedRecord.getBytes("dynBytesBuffer"));
226+
assertArrayEquals(String.valueOf(BYTES0).getBytes(), convertedRecord.getBytes("dynBytesWString"));
227+
assertEquals(BIGDEC.toString(), convertedRecord.getString("dynBigDecimal"));
228+
assertEquals(BIGDEC, new BigDecimal(convertedRecord.getString("dynBigDecimal")));
229+
assertEquals(DOCUMENT.toString(), convertedRecord.getString("dynDocument"));
230+
assertEquals(rowStruct.object0, convertedRecord.get(Object.class, "object0"));
231+
assertTrue(convertedRecord.getBoolean("hAshcOdEdIrtY"));
232+
assertEquals(NAME, convertedRecord.getString("h"));
233233
assertEquals(StudioTypes.CHARACTER, schema.getEntry("char0").getProp(STUDIO_TYPE));
234-
assertEquals(String.valueOf(Character.MAX_VALUE), record.getString("char0"));
235-
assertEquals(dynObject, record.get(Object.class, "dynObject"));
236-
assertEquals(STRINGS, record.getArray(String.class, "STRINGS"));
237-
assertEquals(LONGS, record.getArray(Long.class, "LONGS"));
238-
assertEquals(FLOATS, record.getArray(Float.class, "FLOATS"));
239-
assertEquals(DOUBLES, record.getArray(Double.class, "DOUBLES"));
240-
assertEquals(BOOLEANS, record.getArray(Boolean.class, "BOOLEANS"));
241-
assertEquals(BYTES, record.getArray(byte[].class, "BYTES"));
242-
assertEquals(DATES, record.getArray(ZonedDateTime.class, "DATES"));
243-
assertEquals(RECORDS, record.getArray(Record.class, "RECORDS"));
244-
record.getArray(Record.class, "RECORDS").forEach(r -> {
234+
assertEquals(String.valueOf(Character.MAX_VALUE), convertedRecord.getString("char0"));
235+
assertEquals(dynObject, convertedRecord.get(Object.class, "dynObject"));
236+
assertEquals(STRINGS, convertedRecord.getArray(String.class, "STRINGS"));
237+
assertEquals(LONGS, convertedRecord.getArray(Long.class, "LONGS"));
238+
assertEquals(FLOATS, convertedRecord.getArray(Float.class, "FLOATS"));
239+
assertEquals(DOUBLES, convertedRecord.getArray(Double.class, "DOUBLES"));
240+
assertEquals(BOOLEANS, convertedRecord.getArray(Boolean.class, "BOOLEANS"));
241+
assertEquals(BYTES, convertedRecord.getArray(byte[].class, "BYTES"));
242+
assertEquals(DATES, convertedRecord.getArray(ZonedDateTime.class, "DATES"));
243+
assertEquals(RECORDS, convertedRecord.getArray(Record.class, "RECORDS"));
244+
convertedRecord.getArray(Record.class, "RECORDS").forEach(r -> {
245245
assertEquals(1, r.getInt("ntgr"));
246246
assertEquals("one", r.getString("str"));
247247
});
248-
assertEquals(BIG_DECIMALS, record.getArray(BigDecimal.class, "BIG_DECIMALS"));
248+
assertEquals(BIG_DECIMALS, convertedRecord.getArray(BigDecimal.class, "BIG_DECIMALS"));
249249
assertEquals(3,
250250
schema.getEntries()
251251
.stream()
252252
.filter(entry -> entry.getName().matches("hAshcOdEdIrtY|h|id"))
253253
.count());
254254
// check list combinations
255-
assertEquals(INTEGERS, record.getArray(Integer.class, "array0"));
256-
assertEquals(LIST_INTEGERS, record.getArray(List.class, "array1"));
257-
assertEquals(LIST_HETEROGENEOUS_INTEGER, record.getArray(List.class, "array2"));
258-
assertEquals(LIST_HETEROGENEOUS_LIST, record.getArray(List.class, "array3"));
259-
assertEquals(LIST_INTEGERS_EMPTY, record.getArray(List.class, "array4"));
260-
assertEquals(LIST_3_DEEP, record.getArray(List.class, "array5"));
255+
assertEquals(INTEGERS, convertedRecord.getArray(Integer.class, "array0"));
256+
assertEquals(LIST_INTEGERS, convertedRecord.getArray(List.class, "array1"));
257+
assertEquals(LIST_HETEROGENEOUS_INTEGER, convertedRecord.getArray(List.class, "array2"));
258+
assertEquals(LIST_HETEROGENEOUS_LIST, convertedRecord.getArray(List.class, "array3"));
259+
assertEquals(LIST_INTEGERS_EMPTY, convertedRecord.getArray(List.class, "array4"));
260+
assertEquals(LIST_3_DEEP, convertedRecord.getArray(List.class, "array5"));
261261
// check their schemas
262262
assertSchemaArray0(schema);
263263
assertSchemaArray1(schema);
@@ -273,9 +273,9 @@ void visit() {
273273
.stream()
274274
.filter(entry -> entry.getName().matches("hashCodeDirty|loopKey|lookKey"))
275275
.count());
276-
assertThrows(NullPointerException.class, () -> record.getBoolean("hashCodeDirty"));
277-
assertNull(record.getString("loopKey"));
278-
assertNull(record.getString("lookKey"));
276+
assertThrows(NullPointerException.class, () -> convertedRecord.getBoolean("hashCodeDirty"));
277+
assertNull(convertedRecord.getString("loopKey"));
278+
assertNull(convertedRecord.getString("lookKey"));
279279
}
280280

281281
private static void assertSchemaArray0(final Schema schema) {
@@ -431,11 +431,11 @@ public void readData(final ObjectInputStream objectInputStream) {
431431
createMetadata(rowStruct.dynamic, name3, StudioTypes.LIST, STRINGS, null, true, originalName3);
432432

433433
final DiRowStructVisitor visitor = new DiRowStructVisitor();
434-
final Record record = visitor.get(rowStruct, factory);
434+
final Record convertedRecord = visitor.get(rowStruct, factory);
435435

436436
// validation
437437
// schema
438-
final Schema schema = record.getSchema();
438+
final Schema schema = convertedRecord.getSchema();
439439
assertEquals(3, schema.getEntries().size());
440440
{
441441
final Entry testedEntry = schema.getEntry(name1);
@@ -472,9 +472,9 @@ public void readData(final ObjectInputStream objectInputStream) {
472472
}
473473

474474
// value
475-
assertEquals(STRINGS, record.getArray(String.class, name1));
476-
assertEquals(STRINGS, record.getArray(String.class, name2));
477-
assertEquals(STRINGS, record.getArray(String.class, name3));
475+
assertEquals(STRINGS, convertedRecord.getArray(String.class, name1));
476+
assertEquals(STRINGS, convertedRecord.getArray(String.class, name2));
477+
assertEquals(STRINGS, convertedRecord.getArray(String.class, name3));
478478
}
479479

480480
@Test
@@ -515,11 +515,11 @@ public void readData(final ObjectInputStream objectInputStream) {
515515
rowStruct.dynamic.metadatas.get(1).setPrecision(7);
516516

517517
final DiRowStructVisitor visitor = new DiRowStructVisitor();
518-
final Record record = visitor.get(rowStruct, factory);
518+
final Record convertedRecord = visitor.get(rowStruct, factory);
519519

520520
// validation
521521
// schema
522-
final Schema schema = record.getSchema();
522+
final Schema schema = convertedRecord.getSchema();
523523
assertEquals(2, schema.getEntries().size());
524524
{
525525
final Entry testedEntry = schema.getEntry(name1);
@@ -545,8 +545,8 @@ public void readData(final ObjectInputStream objectInputStream) {
545545
}
546546

547547
// value
548-
assertEquals(BigDecimal.valueOf(42L), record.getDecimal(name1));
549-
assertEquals(BigDecimal.valueOf(42L), record.getDecimal(name2));
548+
assertEquals(BigDecimal.valueOf(42L), convertedRecord.getDecimal(name1));
549+
assertEquals(BigDecimal.valueOf(42L), convertedRecord.getDecimal(name2));
550550
}
551551

552552
@Test
@@ -577,11 +577,11 @@ public void readData(final ObjectInputStream objectInputStream) {
577577
createMetadata(rowStruct.dynamic, name2, StudioTypes.BIGDECIMAL, BigDecimal.valueOf(42L));
578578

579579
final DiRowStructVisitor visitor = new DiRowStructVisitor();
580-
final Record record = visitor.get(rowStruct, factory);
580+
final Record convertedRecord = visitor.get(rowStruct, factory);
581581

582582
// validation
583583
// schema
584-
final Schema schema = record.getSchema();
584+
final Schema schema = convertedRecord.getSchema();
585585
assertEquals(2, schema.getEntries().size());
586586
{
587587
final Entry testedEntry = schema.getEntry(name1);
@@ -607,8 +607,8 @@ public void readData(final ObjectInputStream objectInputStream) {
607607
}
608608

609609
// value
610-
assertTrue(record.getOptionalDecimal(name1).isEmpty());
611-
assertEquals(BigDecimal.valueOf(42L), record.getDecimal(name2));
610+
assertTrue(convertedRecord.getOptionalDecimal(name1).isEmpty());
611+
assertEquals(BigDecimal.valueOf(42L), convertedRecord.getDecimal(name2));
612612
}
613613

614614
@Test
@@ -640,9 +640,9 @@ public void readData(final ObjectInputStream objectInputStream) {
640640
rowStruct.array1 = LIST_INTEGERS;
641641

642642
final DiRowStructVisitor visitor = new DiRowStructVisitor();
643-
final Record record = visitor.get(rowStruct, factory);
643+
final Record convertedRecord = visitor.get(rowStruct, factory);
644644

645-
final Schema schema = record.getSchema();
645+
final Schema schema = convertedRecord.getSchema();
646646
assertEquals(2, schema.getEntries().size());
647647

648648
// schema metadata
@@ -666,8 +666,8 @@ public void readData(final ObjectInputStream objectInputStream) {
666666

667667
// asserts Record
668668
// check list combinations
669-
assertEquals(INTEGERS, record.getArray(Integer.class, "array0"));
670-
assertEquals(LIST_INTEGERS, record.getArray(List.class, "array1"));
669+
assertEquals(INTEGERS, convertedRecord.getArray(Integer.class, "array0"));
670+
assertEquals(LIST_INTEGERS, convertedRecord.getArray(List.class, "array1"));
671671

672672
// check their schemas
673673
assertSchemaArray0(schema);
@@ -684,17 +684,17 @@ public static class Rcd {
684684
@Data
685685
public static class RowStructEmptyNull implements routines.system.IPersistableRow {
686686

687-
public Integer meta_id;
687+
public Integer meta_id; //NOSONAR
688688

689-
public String FirstName;
689+
public String FirstName; //NOSONAR
690690

691691
public String lastName;
692692

693-
public String City;
693+
public String City; //NOSONAR
694694

695695
public String i;
696696

697-
public String A;
697+
public String A; //NOSONAR
698698

699699
@Override
700700
public void writeData(final ObjectOutputStream objectOutputStream) {

0 commit comments

Comments
 (0)