Skip to content

Commit

Permalink
Fixes #446 - improve test coverage
Browse files Browse the repository at this point in the history
* Added direct tests from some new classes
* Broke up some of the geocoding tests to not be so huge
  • Loading branch information
dickschoeller committed Jun 25, 2017
1 parent 1d5ffea commit 218e667
Show file tree
Hide file tree
Showing 12 changed files with 1,015 additions and 753 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.schoellerfamily.gedbrowser.datamodel.visitor.test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.schoellerfamily.gedbrowser.datamodel.Person;
import org.schoellerfamily.gedbrowser.datamodel.util.GedObjectBuilder;
import org.schoellerfamily.gedbrowser.datamodel.visitor.PersonConfidentialVisitor;

/**
* @author Dick Schoeller
*/
public class PersonConfidentialVisitorTest {
/** */
private final GedObjectBuilder builder = new GedObjectBuilder();

/** */
@Test
public void testNotConfidential() {
final Person person =
builder.createPerson("I1", "J. Random/Schoeller/");
final PersonConfidentialVisitor visitor =
new PersonConfidentialVisitor();
person.accept(visitor);
assertFalse("Should not be confidential", visitor.isConfidential());
}

/** */
@Test
public void testIsConfidential() {
final Person person =
builder.createPerson("I1", "J. Random/Schoeller/");
builder.createAttribute(person, "Restriction", "confidential");
final PersonConfidentialVisitor visitor =
new PersonConfidentialVisitor();
person.accept(visitor);
assertTrue("Should be confidential", visitor.isConfidential());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
* @author Dick Schoeller
*/
public final class SourceRenderer extends GedRenderer<Source>
implements IndexHrefRenderer<Source>, HeaderHrefRenderer<Source>,
SubmittorsHrefRenderer<Source>, SourcesHrefRenderer<Source> {
implements HeaderHrefRenderer<Source>, IndexHrefRenderer<Source>,
PlacesHrefRenderer<Source>, SourcesHrefRenderer<Source>,
SubmittorsHrefRenderer<Source> {
/**
* @param gedObject the Source that we are going to render
* @param rendererFactory the factory that creates the renderers for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,18 @@ public void testSubmittorsMenuItem() throws IOException {
assertEquals("sources href mismatch",
"submittors?db=gl120368", renderer.getSubmittorsHref());
}

/**
* Test whether the menu items are as expected.
*
* @throws IOException if can't read data file
*/
@Test
public void testPlacesMenuItem() throws IOException {
final Root root = reader.readFileTestSource();
final IndexRenderer renderer = new IndexRenderer(root, "A",
anonymousContext);
assertEquals("places href mismatch", "places?db=gl120368",
renderer.getPlacesHref());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,17 @@ public void testSubmittorsMenuItem() throws IOException {
assertEquals("sources href mismatch",
"submittors?db=gl120368", renderer.getSubmittorsHref());
}

/**
* Test whether the menu items are as expected.
*
* @throws IOException if can't read data file
*/
@Test
public void testPlacesMenuItem() throws IOException {
final Root root1 = reader.readFileTestSource();
final LivingRenderer renderer = new LivingRenderer(root1, userContext);
assertEquals("places href mismatch", "places?db=gl120368",
renderer.getPlacesHref());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1509,6 +1509,22 @@ public void testSubmittorsMenuItem() throws IOException {
}
}

/**
* Test whether the menu items are as expected.
*
* @throws IOException if can't read data file
*/
@Test
public void testPlacesMenuItem() throws IOException {
final Root root = reader.readFileTestSource();
final Collection<Person> persons = root.find(Person.class);
for (final Person person : persons) {
final PersonRenderer renderer = createRenderer(person);
assertEquals("places href mismatch",
"places?db=gl120368", renderer.getPlacesHref());
}
}

/**
* @param person the person
* @return the renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,22 @@ public void testSubmittorsMenuItem() throws IOException {
}
}

/**
* Test whether the menu items are as expected.
*
* @throws IOException if can't read data file
*/
@Test
public void testPlacesMenuItem() throws IOException {
final Root root = reader.readFileTestSource();
final Collection<Source> sources = root.find(Source.class);
for (final Source source : sources) {
final SourceRenderer renderer = createRenderer(source);
assertEquals("places href mismatch", "places?db=gl120368",
renderer.getPlacesHref());
}
}

/**
* @param source the source
* @return the renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.runner.RunWith;
import org.schoellerfamily.gedbrowser.datamodel.Root;
import org.schoellerfamily.gedbrowser.reader.testreader.TestDataReader;
import org.schoellerfamily.gedbrowser.renderer.LivingRenderer;
import org.schoellerfamily.gedbrowser.renderer.RenderingContext;
import org.schoellerfamily.gedbrowser.renderer.SourceRenderer;
import org.schoellerfamily.gedbrowser.renderer.SourcesRenderer;
Expand Down Expand Up @@ -155,4 +156,18 @@ public void testSubmittorsMenuItem() throws IOException {
assertEquals("sources href mismatch",
"submittors?db=gl120368", renderer.getSubmittorsHref());
}

/**
* Test whether the menu items are as expected.
*
* @throws IOException if can't read data file
*/
@Test
public void testPlacesMenuItem() throws IOException {
final Root root1 = reader.readFileTestSource();
final SourcesRenderer renderer = new SourcesRenderer(root1,
anonymousContext);
assertEquals("places href mismatch", "places?db=gl120368",
renderer.getPlacesHref());
}
}

0 comments on commit 218e667

Please sign in to comment.