Skip to content

Commit 6cbfe71

Browse files
authored
Update tests to reflect breaking changes in 5.0 (#1163)
1 parent f4c3d6d commit 6cbfe71

File tree

5 files changed

+23
-22
lines changed

5 files changed

+23
-22
lines changed

driver/src/test/java/org/neo4j/driver/integration/ErrorIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,17 @@ void shouldExplainConnectionError()
155155
void shouldHandleFailureAtRunTime()
156156
{
157157
String label = UUID.randomUUID().toString(); // avoid clashes with other tests
158-
158+
String query = "CREATE CONSTRAINT ON (a:`" + label + "`) ASSERT a.name IS UNIQUE";
159159
// given
160160
Transaction tx = session.beginTransaction();
161-
tx.run( "CREATE CONSTRAINT ON (a:`" + label + "`) ASSERT a.name IS UNIQUE" );
161+
tx.run( query );
162162
tx.commit();
163163

164164
// and
165165
Transaction anotherTx = session.beginTransaction();
166166

167167
// then expect
168-
ClientException e = assertThrows( ClientException.class, () -> anotherTx.run( "CREATE INDEX ON :`" + label + "`(name)" ) );
168+
ClientException e = assertThrows( ClientException.class, () -> anotherTx.run( query ) );
169169
anotherTx.rollback();
170170
assertThat( e.getMessage(), containsString( label ) );
171171
assertThat( e.getMessage(), containsString( "name" ) );

driver/src/test/java/org/neo4j/driver/integration/SessionIT.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,9 +770,9 @@ void shouldThrowRunFailureImmediatelyAndCloseSuccessfully()
770770
{
771771
try ( Session session = neo4j.driver().session() )
772772
{
773-
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 10 / 0" ) );
773+
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 1 * \"x\"" ) );
774774

775-
assertThat( e.getMessage(), containsString( "/ by zero" ) );
775+
assertThat( e.getMessage(), containsString( "Type mismatch" ) );
776776
}
777777
}
778778

@@ -804,9 +804,10 @@ void shouldThrowRunFailureImmediatelyAfterMultipleSuccessfulRunsAndCloseSuccessf
804804
{
805805
session.run( "CREATE ()" );
806806
session.run( "CREATE ()" );
807-
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 10 / 0" ) );
808807

809-
assertThat( e.getMessage(), containsString( "/ by zero" ) );
808+
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 1 * \"x\"" ) );
809+
810+
assertThat( e.getMessage(), containsString( "Type mismatch" ) );
810811
}
811812
}
812813

@@ -817,8 +818,8 @@ void shouldThrowRunFailureImmediatelyAndAcceptSubsequentRun()
817818
{
818819
session.run( "CREATE ()" );
819820
session.run( "CREATE ()" );
820-
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 10 / 0" ) );
821-
assertThat( e.getMessage(), containsString( "/ by zero" ) );
821+
ClientException e = assertThrows( ClientException.class, () -> session.run( "RETURN 1 * \"x\"" ) );
822+
assertThat( e.getMessage(), containsString( "Type mismatch" ) );
822823
session.run( "CREATE ()" );
823824
}
824825
}

driver/src/test/java/org/neo4j/driver/integration/SummaryIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
import java.util.List;
2727
import java.util.concurrent.TimeUnit;
2828

29-
import org.neo4j.driver.Session;
3029
import org.neo4j.driver.Result;
30+
import org.neo4j.driver.Session;
3131
import org.neo4j.driver.Value;
3232
import org.neo4j.driver.Values;
3333
import org.neo4j.driver.internal.util.EnabledOnNeo4jWith;
3434
import org.neo4j.driver.internal.util.Neo4jFeature;
3535
import org.neo4j.driver.summary.Notification;
3636
import org.neo4j.driver.summary.Plan;
3737
import org.neo4j.driver.summary.ProfiledPlan;
38-
import org.neo4j.driver.summary.ResultSummary;
3938
import org.neo4j.driver.summary.QueryType;
39+
import org.neo4j.driver.summary.ResultSummary;
4040
import org.neo4j.driver.util.DatabaseExtension;
4141
import org.neo4j.driver.util.ParallelizableIT;
4242

@@ -125,12 +125,12 @@ void shouldContainCorrectStatistics()
125125
assertTrue( session.run( "CREATE (n {magic: 42})" ).consume().counters().containsUpdates() );
126126
assertThat( session.run( "MATCH (n:ALabel) REMOVE n:ALabel " ).consume().counters().labelsRemoved(), equalTo( 1 ) );
127127

128-
assertThat( session.run( "CREATE INDEX ON :ALabel(prop)" ).consume().counters().indexesAdded(), equalTo( 1 ) );
129-
assertThat( session.run( "DROP INDEX ON :ALabel(prop)" ).consume().counters().indexesRemoved(), equalTo( 1 ) );
128+
assertThat( session.run( "CREATE INDEX superIndex FOR (n:ALabel) ON (n.prop)" ).consume().counters().indexesAdded(), equalTo( 1 ) );
129+
assertThat( session.run( "DROP INDEX superIndex" ).consume().counters().indexesRemoved(), equalTo( 1 ) );
130130

131-
assertThat( session.run( "CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE" )
131+
assertThat( session.run( "CREATE CONSTRAINT restrictedConstraint ON (book:Book) ASSERT book.isbn IS UNIQUE" )
132132
.consume().counters().constraintsAdded(), equalTo( 1 ) );
133-
assertThat( session.run( "DROP CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE" )
133+
assertThat( session.run( "DROP CONSTRAINT restrictedConstraint" )
134134
.consume().counters().constraintsRemoved(), equalTo( 1 ) );
135135
}
136136

driver/src/test/java/org/neo4j/driver/integration/async/AsyncSessionIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,17 +700,17 @@ public CompletionStage<String> execute( AsyncTransaction tx )
700700
@Test
701701
void shouldNotPropagateRunFailureWhenClosed()
702702
{
703-
session.runAsync( "RETURN 10 / 0" );
703+
session.runAsync( "RETURN 1 * \"x\"" );
704704

705705
await( session.closeAsync() );
706706
}
707707

708708
@Test
709709
void shouldPropagateRunFailureImmediately()
710710
{
711-
ClientException e = assertThrows( ClientException.class, () -> await( session.runAsync( "RETURN 10 / 0" ) ) );
711+
ClientException e = assertThrows( ClientException.class, () -> await( session.runAsync( "RETURN 1 * \"x\"" ) ) );
712712

713-
assertThat( e.getMessage(), containsString( "/ by zero" ) );
713+
assertThat( e.getMessage(), containsString( "Type mismatch" ) );
714714
}
715715

716716
@Test

driver/src/test/java/org/neo4j/driver/integration/async/AsyncTransactionIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ void shouldFailToCommitWhenQueriesFail()
664664

665665
tx.runAsync( "CREATE (:TestNode)" );
666666
tx.runAsync( "CREATE (:TestNode)" );
667-
tx.runAsync( "RETURN 10 / 0" );
667+
tx.runAsync( "RETURN 1 * \"x\"" );
668668
tx.runAsync( "CREATE (:TestNode)" );
669669

670670
ClientException e = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
@@ -690,10 +690,10 @@ void shouldFailToCommitWhenBlockedRunFailed()
690690
{
691691
AsyncTransaction tx = await( session.beginTransactionAsync() );
692692

693-
ClientException runException = assertThrows( ClientException.class, () -> await( tx.runAsync( "RETURN 42 / 0" ) ) );
693+
ClientException runException = assertThrows( ClientException.class, () -> await( tx.runAsync( "RETURN 1 * \"x\"" ) ) );
694694

695695
ClientException commitException = assertThrows( ClientException.class, () -> await( tx.commitAsync() ) );
696-
assertThat( runException.getMessage(), containsString( "/ by zero" ) );
696+
assertThat( runException.getMessage(), containsString( "Type mismatch" ) );
697697
assertNoCircularReferences( commitException );
698698
assertThat( commitException.getMessage(), containsString( "Transaction can't be committed" ) );
699699
}
@@ -713,7 +713,7 @@ void shouldRollbackSuccessfullyWhenBlockedRunFailed()
713713
{
714714
AsyncTransaction tx = await( session.beginTransactionAsync() );
715715

716-
assertThrows( ClientException.class, () -> await( tx.runAsync( "RETURN 42 / 0" ) ) );
716+
assertThrows( ClientException.class, () -> await( tx.runAsync( "RETURN 1 * \"x\"" ) ) );
717717

718718
await( tx.rollbackAsync() );
719719
}

0 commit comments

Comments
 (0)