/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipManyGenerations() { Individual alex = getPerson("Zucco", "Alex"); Individual abigail = getPerson("Wood", "Abigail"); rc.calculateRelationships(alex, abigail, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + abigail); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals( "Abigail is Alex's great-great-grandmother - there are several ways to get there but one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(alex, r.getIndividual1()); assertEquals(abigail, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be four hops long (after collapsing)", 1, r.getChain().size()); assertEquals( "The relationship should be an great-great-grandmother/great-great-grandson one", GREAT_GREAT_GRANDMOTHER, r.getChain().get(0).getName()); rc.calculateRelationships(abigail, alex, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + abigail); for (Relationship r1 : rc.getRelationshipsFound()) { System.out.println(" " + r1); } } assertEquals( "Abigail is Alex's great-great-grandmother - there are several ways to get there but one relationship", 1, rc.getRelationshipsFound().size()); r = rc.getRelationshipsFound().get(0); assertEquals(abigail, r.getIndividual1()); assertEquals(alex, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be one hops long (after collapsing)", 1, r.getChain().size()); assertEquals( "The relationship should be an great-great-grandmother/great-great-grandson one", GREAT_GREAT_GRANDSON, r.getChain().get(0).getName()); }
/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipGreatGreatGreatGrandparents() { Individual alex = getPerson("Zucco", "Alex"); Individual kenneth = getPerson("Struthers", "Kenneth"); rc.calculateRelationships(alex, kenneth, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + kenneth); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals( "Kenneth is Alex's great-great-great-grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(alex, r.getIndividual1()); assertEquals(kenneth, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be two hops long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be a great-great-great-grandfather/great-great-great-grandfather one", GREAT_GREAT_GREAT_GRANDFATHER, r.getChain().get(0).getName()); rc.calculateRelationships(kenneth, alex, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + kenneth); for (Relationship r1 : rc.getRelationshipsFound()) { System.out.println(" " + r1); } } assertEquals( "Kenneth is Alex's great-great-great-grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); r = rc.getRelationshipsFound().get(0); assertEquals(kenneth, r.getIndividual1()); assertEquals(alex, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be 1 hops long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be a great-great-great-grandfather/great-great-great-grandfather one", GREAT_GREAT_GREAT_GRANDSON, r.getChain().get(0).getName()); }
/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipGreatGrandparents() { Individual nancy = getPerson("Andrews", "Nancy"); Individual steven = getPerson("Struthers", "Steven"); rc.calculateRelationships(nancy, steven, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + nancy + " and " + steven); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals( "Steven is Nancy's great-grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(nancy, r.getIndividual1()); assertEquals(steven, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be two hops long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be a great-grandfather/great-granddaughter one", GREAT_GRANDFATHER, r.getChain().get(0).getName()); rc.calculateRelationships(steven, nancy, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + nancy + " and " + steven); for (Relationship r1 : rc.getRelationshipsFound()) { System.out.println(" " + r1); } } assertEquals( "Steven is Nancy's great-grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); r = rc.getRelationshipsFound().get(0); assertEquals(steven, r.getIndividual1()); assertEquals(nancy, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be 1 hop long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be a great-grandfather/great-granddaughter one", GREAT_GRANDDAUGHTER, r.getChain().get(0).getName()); }
/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipGrandparents() { Individual robert = getPerson("Andrews", "Robert"); Individual steven = getPerson("Struthers", "Steven"); rc.calculateRelationships(robert, steven, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + robert + " and " + steven); for (Relationship r1 : rc.getRelationshipsFound()) { System.out.println(" " + r1); } } assertEquals( "Steven is Robert's grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(robert, r.getIndividual1()); assertEquals(steven, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be one hop long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be an grandfather/grandson one", GRANDFATHER, r.getChain().get(0).getName()); rc.calculateRelationships(steven, robert, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + robert + " and " + steven); for (Relationship r1 : rc.getRelationshipsFound()) { System.out.println(" " + r1); } } assertEquals( "Steven is Robert's grandfather - there should be one relationship", 1, rc.getRelationshipsFound().size()); r = rc.getRelationshipsFound().get(0); assertEquals(steven, r.getIndividual1()); assertEquals(robert, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be one hop long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be an grandfather/grandson one", GRANDSON, r.getChain().get(0).getName()); }
/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipSonFather() { Individual james = getPerson("Andrews", "James"); Individual robert = getPerson("Andrews", "Robert"); rc.calculateRelationships(robert, james, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + robert + " and " + james); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals( "James is robert's father - there should be one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(robert, r.getIndividual1()); assertEquals(james, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals("The relationship length should be one hop long", 1, r.getChain().size()); assertEquals( "The relationship should be an father/son one", FATHER, r.getChain().get(0).getName()); }
/** Test for {@link RelationshipCalculator}, for aunts/uncles */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testAuntsUncles() { Individual alex = getPerson("Zucco", "Alex"); Individual theresa = getPerson("Andrews", "Theresa"); rc.calculateRelationships(alex, theresa, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + theresa); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals("Theres is alex's aunt, one relationship", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(alex, r.getIndividual1()); assertEquals(theresa, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals("The relationship should be one item long", 1, r.getChain().size()); assertEquals( "The relationship should be an aunt/nephew one", AUNT, r.getChain().get(0).getName()); }
/** * Test method for {@link * RelationshipCalculator#calculateRelationships(org.gedcom4j.model.Individual, * org.gedcom4j.model.Individual, boolean)} . */ @Test @SuppressWarnings("PMD.SystemPrintln") public void testCalculateRelationshipSiblings() { Individual alex = getPerson("Zucco", "Alex"); Individual betsy = getPerson("Zucco", "Betsy"); rc.calculateRelationships(alex, betsy, true); assertNotNull(rc.getRelationshipsFound()); if (VERBOSE) { System.out.println("Relationships between " + alex + " and " + betsy); for (Relationship r : rc.getRelationshipsFound()) { System.out.println(" " + r); } } assertEquals("Betsy is Alex's sister", 1, rc.getRelationshipsFound().size()); Relationship r = rc.getRelationshipsFound().get(0); assertEquals(alex, r.getIndividual1()); assertEquals(betsy, r.getIndividual2()); assertNotNull(r.getChain()); assertEquals( "The relationship length should be one hops long after collapsing", 1, r.getChain().size()); assertEquals( "The relationship should be an sister/brother one", SISTER, r.getChain().get(0).getName()); }