Skip to content

Commit

Permalink
coverage without jooq
Browse files Browse the repository at this point in the history
  • Loading branch information
KTC-YoheiMiyashita committed Dec 24, 2024
1 parent d0f71a3 commit 78f56a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dbAndCsvBatch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ jacocoTestReport {
csv.required = true
html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
}

// Exclude packages or classes from the coverage report
afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
'com/example/batch/jooq/**'
])
})
)
}
}

// https://github.com/diffplug/spotless
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,32 @@ void testDelete() {
assertTrue(selected.isEmpty(), "Expected no records after deletion.");
}

@Test
void testBulkInsert() {
// Prepare test data
List<MemberRecord> members =
List.of(
createMemberRecord("Test1", "[email protected]", "1234567890", "Address 1", (byte) 100),
createMemberRecord(
"Test2", "[email protected]", "0987654321", "Address 2", (byte) 100));

// Execute bulkInsert
repository.bulkInsert(members);

// Verify inserted data
List<MemberRecord> selected =
repository.selectByTypeAndDeleteFlag(List.of((byte) 100), (byte) 0);
assertEquals(2, selected.size(), "Expected 2 records to be inserted.");

assertEquals("Test1", selected.get(0).getName(), "First record name mismatch.");
assertEquals("Test2", selected.get(1).getName(), "Second record name mismatch.");
assertEquals("[email protected]", selected.get(0).getEmail(), "First record email mismatch.");
assertEquals("[email protected]", selected.get(1).getEmail(), "Second record email mismatch.");

// Clean up inserted records
selected.forEach(record -> repository.delete(record.getId()));
}

private void cleanupRecordsByType(byte type) {
List<MemberRecord> existingRecords =
repository.selectByTypeAndDeleteFlag(List.of(type), (byte) 0);
Expand Down

0 comments on commit 78f56a0

Please sign in to comment.