-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/develop' into develop
- Loading branch information
Showing
1 changed file
with
122 additions
and
0 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
...g/monarchinitiative/phenopacket2prompt/output/impl/turkish/PpktIndividualTurkishTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
package org.monarchinitiative.phenopacket2prompt.output.impl.turkish; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import org.monarchinitiative.phenol.base.PhenolRuntimeException; | ||
import org.monarchinitiative.phenopacket2prompt.model.PhenopacketSex; | ||
import org.monarchinitiative.phenopacket2prompt.model.PpktIndividual; | ||
import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualBase; | ||
import org.monarchinitiative.phenopacket2prompt.output.PPKtIndividualInfoGenerator; | ||
import org.monarchinitiative.phenopacket2prompt.output.impl.turkish.PpktIndividualTurkish; | ||
|
||
import java.util.function.Supplier; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class PpktIndividualTurkishTest extends PPKtIndividualBase{ | ||
|
||
|
||
|
||
private static Stream<TestIndividual> testGetIndividualDescription() { | ||
return Stream.of( | ||
new TestIndividual("46 year old female, infantile onset", | ||
female46yearsInfantileOnset(), new TestOutcome.Ok("Proband 46 yaşında bir kadındı. Hastalık infantil döneminde başladı.")), | ||
new TestIndividual("male 4 months, congenital onset", | ||
male4monthsCongenitalOnset(), new TestOutcome.Ok("Proband 4 aylık bir erkek bebekti. Hastalık doğumda başladı.")), | ||
new TestIndividual("female, no onset", | ||
femaleNoAge(), new TestOutcome.Ok("Proband bir kadındı. Hastalığın başlangıcı belirtilmedi.")), | ||
new TestIndividual("female, no HPOs", | ||
femaleNoHPOs(), new TestOutcome.Error(() -> new PhenolRuntimeException("No HPO annotations"))), | ||
new TestIndividual("unknown sex, no 4yo", | ||
unknownSex4YearsOnset(), new TestOutcome.Ok("Proband cinsiyeti belirtilmemiş bir bireydi. Hastalık çocukluk döneminde başladı.")) | ||
); | ||
} | ||
|
||
|
||
|
||
@ParameterizedTest | ||
@MethodSource("testGetIndividualDescription") | ||
void testEvaluateExpression(TestIndividual testCase) { | ||
PPKtIndividualInfoGenerator generator = new PpktIndividualTurkish(); | ||
PpktIndividual ppkti = testCase.ppktIndividual(); | ||
switch (testCase.expectedOutcome()) { | ||
case TestOutcome.Ok(String expectedResult) -> | ||
assertEquals(expectedResult, generator.getIndividualDescription(ppkti), | ||
"Incorrect evaluation for: " + testCase.description()); | ||
case TestOutcome.Error(Supplier<? extends RuntimeException> exceptionSupplier) -> | ||
assertThrows(exceptionSupplier.get().getClass(), | ||
() -> generator.getIndividualDescription(ppkti), | ||
"Incorrect error handling for: " + testCase.description()); | ||
} | ||
} | ||
|
||
|
||
|
||
private static Stream<TestIdvlHeShe> testGetPPKtSex() { | ||
return Stream.of( | ||
new TestIdvlHeShe("female", | ||
PhenopacketSex.FEMALE, new TestOutcome.Ok("o")), | ||
new TestIdvlHeShe("male", | ||
PhenopacketSex.MALE, new TestOutcome.Ok("o")), | ||
new TestIdvlHeShe("proband", | ||
PhenopacketSex.UNKNOWN, new TestOutcome.Ok("kişi")) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("testGetPPKtSex") | ||
void testPPKtSex(TestIdvlHeShe testCase) { | ||
PPKtIndividualInfoGenerator generator = new PpktIndividualTurkish(); | ||
switch (testCase.expectedOutcome()) { | ||
case TestOutcome.Ok(String expectedResult) -> | ||
assertEquals(expectedResult, generator.heSheIndividual(testCase.ppktSex())); | ||
case TestOutcome.Error(Supplier<? extends RuntimeException> exceptionSupplier) -> | ||
assertThrows(exceptionSupplier.get().getClass(), | ||
() -> generator.heSheIndividual(testCase.ppktSex()), | ||
"Incorrect error handling for: " + testCase.description()); | ||
} | ||
} | ||
|
||
|
||
|
||
//public record TestIdvlAtAge(String description, PhenopacketAge ppktAge, TestOutcome expectedOutcome) {} | ||
|
||
|
||
private static Stream<TestIdvlAtAge> testIndlAtAge() { | ||
return Stream.of( | ||
new TestIdvlAtAge("congenital", | ||
congenital, new TestOutcome.Ok("Doğumda")), | ||
new TestIdvlAtAge("infantile", | ||
infantile, new TestOutcome.Ok("Bebeklik döneminde")), | ||
new TestIdvlAtAge("childhood age", | ||
childhood, new TestOutcome.Ok("Çocukken")), | ||
new TestIdvlAtAge("46 years old", | ||
p46y, new TestOutcome.Ok("Yaşında 46 yaşında")) | ||
); | ||
} | ||
|
||
|
||
@ParameterizedTest | ||
@MethodSource("testIndlAtAge") | ||
void testPPKtSex(TestIdvlAtAge testCase) { | ||
PPKtIndividualInfoGenerator generator = new PpktIndividualTurkish(); | ||
switch (testCase.expectedOutcome()) { | ||
case TestOutcome.Ok(String expectedResult) -> | ||
assertEquals(expectedResult, generator.atAgeForVignette(testCase.ppktAge())); | ||
case TestOutcome.Error(Supplier<? extends RuntimeException> exceptionSupplier) -> | ||
assertThrows(exceptionSupplier.get().getClass(), | ||
() -> generator.atAgeForVignette(testCase.ppktAge()), | ||
"Incorrect error handling for: " + testCase.description()); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |