test(training): strengthen TrainingBlockQueryTest assertions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit was merged in pull request #378.
This commit is contained in:
@@ -11,6 +11,7 @@ import org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureTestDatabas
|
|||||||
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
|
import org.springframework.boot.data.jpa.test.autoconfigure.DataJpaTest;
|
||||||
import org.springframework.context.annotation.Import;
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ class TrainingBlockQueryTest {
|
|||||||
.title("Kurrent Brief")
|
.title("Kurrent Brief")
|
||||||
.originalFilename("kurrent.pdf")
|
.originalFilename("kurrent.pdf")
|
||||||
.status(DocumentStatus.UPLOADED)
|
.status(DocumentStatus.UPLOADED)
|
||||||
.trainingLabels(new java.util.HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
kurrentDocId = kurrentDoc.getId();
|
kurrentDocId = kurrentDoc.getId();
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ class TrainingBlockQueryTest {
|
|||||||
.originalFilename("karl.pdf")
|
.originalFilename("karl.pdf")
|
||||||
.status(DocumentStatus.UPLOADED)
|
.status(DocumentStatus.UPLOADED)
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.trainingLabels(new java.util.HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
||||||
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
||||||
@@ -157,7 +158,7 @@ class TrainingBlockQueryTest {
|
|||||||
.originalFilename("karl.pdf")
|
.originalFilename("karl.pdf")
|
||||||
.status(DocumentStatus.UPLOADED)
|
.status(DocumentStatus.UPLOADED)
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.trainingLabels(new java.util.HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
||||||
blockRepository.save(block(doc.getId(), annId, BlockSource.OCR, false));
|
blockRepository.save(block(doc.getId(), annId, BlockSource.OCR, false));
|
||||||
@@ -176,7 +177,7 @@ class TrainingBlockQueryTest {
|
|||||||
.originalFilename("karl.pdf")
|
.originalFilename("karl.pdf")
|
||||||
.status(DocumentStatus.UPLOADED)
|
.status(DocumentStatus.UPLOADED)
|
||||||
.sender(karl)
|
.sender(karl)
|
||||||
.trainingLabels(new java.util.HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
||||||
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
||||||
@@ -194,15 +195,25 @@ class TrainingBlockQueryTest {
|
|||||||
.originalFilename("karl.pdf")
|
.originalFilename("karl.pdf")
|
||||||
.status(DocumentStatus.UPLOADED)
|
.status(DocumentStatus.UPLOADED)
|
||||||
.sender(sender)
|
.sender(sender)
|
||||||
.trainingLabels(new java.util.HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
.trainingLabels(new HashSet<>(Set.of(TrainingLabel.KURRENT_RECOGNITION)))
|
||||||
.build());
|
.build());
|
||||||
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
UUID annId = annotationRepository.save(annotation(doc.getId())).getId();
|
||||||
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, false));
|
||||||
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, true));
|
blockRepository.save(block(doc.getId(), annId, BlockSource.MANUAL, true));
|
||||||
|
|
||||||
long count = blockRepository.countManualKurrentBlocksByPerson(sender.getId());
|
long count = blockRepository.countManualKurrentBlocksByPerson(sender.getId());
|
||||||
|
List<TranscriptionBlock> found = blockRepository.findManualKurrentBlocksByPerson(sender.getId());
|
||||||
|
|
||||||
assertThat(count).isEqualTo(2);
|
assertThat(count).isEqualTo(found.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void countManualKurrentBlocksByPerson_returnsZeroWhenNoBlocksMatch() {
|
||||||
|
Person sender = personRepository.save(Person.builder().firstName("Karl").lastName("Test").build());
|
||||||
|
|
||||||
|
long count = blockRepository.countManualKurrentBlocksByPerson(sender.getId());
|
||||||
|
|
||||||
|
assertThat(count).isZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── helpers ─────────────────────────────────────────────────────────────
|
// ─── helpers ─────────────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user