T1: Deduplicator compile fix + unit tests [checkpoint]
This commit is contained in:
+68
@@ -0,0 +1,68 @@
|
||||
package com.developx.szpitale.ingest.normalize;
|
||||
|
||||
import com.developx.szpitale.model.Person;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class DeduplicatorTest {
|
||||
|
||||
private Deduplicator deduplicator;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
deduplicator = new Deduplicator();
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkFuzzyDuplicates_similarNames_reportedNotMerged() {
|
||||
Person janKowalski = new Person(
|
||||
"person:jan-kowalski",
|
||||
"Jan Kowalski",
|
||||
"Jan Kowalski",
|
||||
List.of(),
|
||||
List.of("https://example.com/1")
|
||||
);
|
||||
Person janKowaski = new Person(
|
||||
"person:jan-kowaski",
|
||||
"Jan Kowaski",
|
||||
"Jan Kowaski",
|
||||
List.of(),
|
||||
List.of("https://example.com/2")
|
||||
);
|
||||
|
||||
List<Person> input = List.of(janKowalski, janKowaski);
|
||||
|
||||
List<Person> result = deduplicator.deduplicate(input);
|
||||
|
||||
assertEquals(2, result.size(), "Should not merge two similar names - both should remain as separate entries");
|
||||
assertTrue(result.stream().anyMatch(p -> p.id().equals("person:jan-kowalski")));
|
||||
assertTrue(result.stream().anyMatch(p -> p.id().equals("person:jan-kowaski")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void deduplicate_exactSlugMatches_merged() {
|
||||
Person first = new Person(
|
||||
"person:jan-kowalski",
|
||||
"Jan Kowalski",
|
||||
"Jan Kowalski",
|
||||
List.of(),
|
||||
List.of("https://example.com/1")
|
||||
);
|
||||
Person second = new Person(
|
||||
"person:jan-kowalski",
|
||||
"Jan Kowalski",
|
||||
"Jan Kowalski",
|
||||
List.of(),
|
||||
List.of("https://example.com/2")
|
||||
);
|
||||
|
||||
List<Person> result = deduplicator.deduplicate(List.of(first, second));
|
||||
|
||||
assertEquals(1, result.size(), "Should merge persons with same slug");
|
||||
assertEquals(2, result.get(0).sourceUrls().size(), "Merged person should have all source URLs");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user