Permalink
Browse files

Upgraded to Neo4j 1.8 RC1

Added new characters etc up to "Dinosaurs on a Plane" episode
Created new FATHER_OF relationship because Rory's dad appears.
  • Loading branch information...
1 parent 0be039e commit 83848236b377aee3d1a131e0ca371c011b5d940f @jimwebber committed Sep 9, 2012
View
@@ -1,3 +1,4 @@
+presentation/*.pdf
out
.shell_history
.classpath
Binary file not shown.
View
@@ -2,15 +2,15 @@
<ivy-module xmlns:m="http://ant.apache.org/ivy/maven" version="2.0">
<info organisation="org.neo4j" module="neo4j-koans"/>
<dependencies>
- <dependency org="org.neo4j.app" name="neo4j-server" rev="1.8.M07">
+ <dependency org="org.neo4j.app" name="neo4j-server" rev="1.8.RC1">
<artifact name="neo4j-server" ext="jar"/>
<artifact name="neo4j-server" m:classifier="static-web" ext="jar"/>
<artifact name="neo4j-server" m:classifier="tests" ext="jar"/>
<exclude org="org.slf4j" />
</dependency>
- <dependency org="org.neo4j" name="server-api" rev="1.8.M07"/>
- <dependency org="org.neo4j" name="neo4j-community" rev="1.8.M07"/>
- <dependency org="org.neo4j" name="neo4j-kernel" rev="1.8.M07">
+ <dependency org="org.neo4j" name="server-api" rev="1.8.RC1"/>
+ <dependency org="org.neo4j" name="neo4j-community" rev="1.8.RC1"/>
+ <dependency org="org.neo4j" name="neo4j-kernel" rev="1.8.RC1">
<artifact name="neo4j-kernel" ext="jar"/>
<artifact name="neo4j-kernel" m:classifier="tests" ext="jar"/>
</dependency>
@@ -75,7 +75,7 @@ public void shouldCountTheNumberOfEpisodes()
ExecutionResult result = engine.execute( cql );
- assertEquals( 246l, result.javaColumnAs( "COUNT(episodes)" ).next() );
+ assertEquals( 248l, result.javaColumnAs( "COUNT(episodes)" ).next() );
}
@@ -153,6 +153,6 @@ public void shouldFindIndividualCompanionsAndEnemiesOfTheDoctor()
ExecutionResult result = engine.execute( cql );
- assertEquals( 151, result.size() );
+ assertEquals( 154, result.size() );
}
}
@@ -78,7 +78,7 @@ public void shouldCountTheEnemiesOfTheDoctor() throws Exception
// SNIPPET_END
List<Map<String, Object>> json = JsonHelper.jsonToList( response );
- int numberOfEnemiesOfTheDoctor = 148;
+ int numberOfEnemiesOfTheDoctor = 151;
assertEquals( numberOfEnemiesOfTheDoctor, json.size() );
}
@@ -167,7 +167,7 @@ public void canAddFirstAndSecondIncarnationInformationForTheDoctor()
// SNIPPET_END
- assertFirstAndSecondDoctorCreatedAndLinkedToActors( universe.getServer().getDatabase().graph );
+ assertFirstAndSecondDoctorCreatedAndLinkedToActors( universe.getServer().getDatabase().getGraph() );
}
@@ -3,6 +3,7 @@
import static org.neo4j.tutorial.DatabaseHelper.ensureRelationshipInDb;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -24,6 +25,7 @@
private ArrayList<String> actors = new ArrayList<String>();
private HashMap<String, Integer> startDates = new HashMap<String, Integer>();
private String wikipediaUri;
+ private String[] children;
public static CharacterBuilder character( String characterName )
{
@@ -107,6 +109,20 @@ public void fact( GraphDatabaseService db )
{
characterNode.setProperty( "wikipedia", wikipediaUri );
}
+
+ if ( children != null )
+ {
+ ensureChildrenInDb( characterNode, children, db );
+ }
+ }
+
+ private static void ensureChildrenInDb( Node characterNode, String[] children, GraphDatabaseService db )
+ {
+ for ( String child : children )
+ {
+ Node childNode = ensureCharacterIsInDb( child, db );
+ ensureRelationshipInDb( characterNode, DoctorWhoRelationships.FATHER_OF, childNode );
+ }
}
public static void ensureAllyOfRelationshipInDb( Node allyNode, GraphDatabaseService db )
@@ -308,17 +324,14 @@ public CharacterBuilder isAlly()
public CharacterBuilder regeneration( String... actors )
{
- for ( String actor : actors )
- {
- this.actors.add( actor );
- }
+ Collections.addAll( this.actors, actors );
return this;
}
public CharacterBuilder regeneration( String actor, int year )
{
this.actors.add( actor );
- this.startDates.put( actor, new Integer( year ) );
+ this.startDates.put( actor, year );
return this;
}
@@ -327,4 +340,10 @@ public CharacterBuilder wikipedia( String wikipediaEntry )
this.wikipediaUri = wikipediaEntry;
return this;
}
+
+ public CharacterBuilder fatherOf( String... children )
+ {
+ this.children = children;
+ return this;
+ }
}
@@ -173,10 +173,31 @@ private void loadEnemies()
character( "Yartek" ).isA( "Voord" )
.isEnemy()
.fact( db );
+ character( "Darla von Karlsen" ).isA( "Human" )
+ .isA( "Dalek" )
+ .isEnemy()
+ .fact( db );
+ character( "Harvey" ).isA( "Human" )
+ .isA( "Dalek" )
+ .isEnemy()
+ .fact( db );
+ character( "Solomon" ).isA( "Humanoid" )
+ .isEnemy()
+ .fact( db );
}
private void loadAllies()
{
+ character( "Riddell" ).isA( "Human" )
+ .isAlly()
+ .fact( db );
+ character( "Brian Williams" ).isA( "Human" )
+ .fatherOf( "Rory Williams" )
+ .isAlly()
+ .fact( db );
+ character( "Queen Nefertiti" ).isA( "Human" )
+ .isAlly()
+ .fact( db );
character( "River Song" ).isA( "Human" )
.loves( "Doctor" )
.isAlly()
@@ -218,15 +239,6 @@ private void loadAllies()
.isA( "Dalek" )
.isAlly()
.fact( db );
- character( "Darla von Karlsen" ).isA( "Human" )
- .isA( "Dalek" )
- .isAlly()
- .fact( db );
- character( "Harvey" ).isA( "Human" )
- .isA( "Dalek" )
- .isAlly()
- .isFrom( "Skaro" )
- .fact( db );
}
private void loadCompanions()
@@ -20,5 +20,6 @@
ORIGINAL_PROP,
PREVIOUS,
NEXT,
+ FATHER_OF,
MEMBER_OF
}
@@ -113,7 +113,14 @@ private void season33()
.allies( "Oswin Oswald" )
.companion( "Amy Pond", "Rory Williams" )
.enemySpecies( "Dalek" )
- .enemy("Darla von Karlsen", "Harvey")
+ .enemy( "Darla von Karlsen", "Harvey" )
+ .fact( db );
+
+ episode( 226 ).title( "Dinosaurs on a Spaceship" )
+ .doctor( "Matt Smith" )
+ .allies( "Queen Nefertiti", "Riddell", "Brian Williams" )
+ .companion( "Amy Pond", "Rory Williams" )
+ .enemy( "Solomon" )
.fact( db );
}
@@ -134,7 +134,7 @@ public void shouldHaveCorrectNumberOfHumans()
humanSpeciesNode.getRelationships(
DoctorWhoRelationships.IS_A, Direction.INCOMING ) );
- int knownNumberOfHumans = 48;
+ int knownNumberOfHumans = 54;
assertEquals( knownNumberOfHumans, numberOfHumansFriendliesInTheDB );
}
@@ -385,7 +385,7 @@ else if ( path.length() > 2 )
List<Node> enemiesOfEnemies = databaseHelper.toListOfNodes( nodes );
- int numberOfIndividualAndSpeciesEnemiesInTheDatabase = 147;
+ int numberOfIndividualAndSpeciesEnemiesInTheDatabase = 150;
assertEquals( numberOfIndividualAndSpeciesEnemiesInTheDatabase, enemiesOfEnemies.size() );
assertTrue( isInList( dalek, enemiesOfEnemies ) );
assertTrue( isInList( cyberman, enemiesOfEnemies ) );
@@ -449,7 +449,7 @@ public void shouldHaveCorrectNumberOfCompanionsInTotal()
@Test
public void shouldHaveCorrectNumberofIndividualEnemyCharactersInTotal()
{
- int numberOfEnemies = 105;
+ int numberOfEnemies = 108;
Node theDoctor = universe.getDatabase()
.index()

0 comments on commit 8384823

Please sign in to comment.