Skip to content

Commit

Permalink
Fixed Notification Acceptence Test after review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lojjs committed Sep 29, 2017
1 parent c33eebb commit b4dde89
Showing 1 changed file with 78 additions and 9 deletions.
Expand Up @@ -347,12 +347,20 @@ public void shouldNotNotifyOnNonExistingPropKeyIdUsingLoadCSV() throws Exception
} }


@Test @Test
public void shouldNotNotifyOnEagerBeforeLoadCSV() throws Exception public void shouldNotNotifyOnEagerBeforeLoadCSVDelete() throws Exception
{ {
Stream.of( "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> shouldNotNotifyInStream( version, Stream.of( "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> shouldNotNotifyInStream( version,
"EXPLAIN MATCH (n) DELETE n WITH * LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MERGE () RETURN line" ) ); "EXPLAIN MATCH (n) DELETE n WITH * LOAD CSV FROM 'file:///ignore/ignore.csv' AS line MERGE () RETURN line" ) );
} }


@Test
public void shouldNotNotifyOnEagerBeforeLoadCSVCreate() throws Exception
{
Stream.of( "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version ->
assertNotifications( version +"EXPLAIN MATCH (a), (b) CREATE (c) WITH c LOAD CSV FROM 'file:///ignore/ignore.csv' AS line RETURN *",
containsNoItem( eagerOperatorWarning ) ) );
}

@Test @Test
public void shouldWarnOnEagerAfterLoadCSV() throws Exception public void shouldWarnOnEagerAfterLoadCSV() throws Exception
{ {
Expand Down Expand Up @@ -495,7 +503,8 @@ public void shouldWarnOnDynamicPropertyLookupWithBothStaticAndDynamicProperties(
{ {
db().execute( "CREATE INDEX ON :Person(name)" ); db().execute( "CREATE INDEX ON :Person(name)" );
db().execute( "Call db.awaitIndexes()" ); db().execute( "Call db.awaitIndexes()" );
shouldNotNotifyInStream( version, "EXPLAIN MATCH (n) WHERE n['key-' + n.name] = 'value' RETURN n" ); assertNotifications( version + "EXPLAIN MATCH (n:Person) WHERE n.name = 'Tobias' AND n['key-' + n.name] = 'value' RETURN n",
containsItem( dynamicPropertyWarning ));
} ); } );
} }


Expand All @@ -511,7 +520,8 @@ public void shouldNotNotifyOnDynamicPropertyLookupWithLabelHavingNoIndex() throw
db().createNode().addLabel( label( "Foo" ) ); db().createNode().addLabel( label( "Foo" ) );
tx.success(); tx.success();
} }
shouldNotNotifyInStream( version, "EXPLAIN MATCH (n) WHERE n['key-' + n.name] = 'value' RETURN n" ); shouldNotNotifyInStream( version, "EXPLAIN MATCH (n:Foo) WHERE n['key-' + n.name] = 'value' RETURN n" );

} ); } );
} }


Expand Down Expand Up @@ -568,6 +578,19 @@ public void shouldNotNotifyOnDynamicPropertyLookupWithSingleLabelAndNegativePred


@Test @Test
public void shouldWarnOnUnfulfillableIndexSeekUsingDynamicPropertyAndMultipleLabels() throws Exception public void shouldWarnOnUnfulfillableIndexSeekUsingDynamicPropertyAndMultipleLabels() throws Exception
{
Stream.of( "CYPHER 3.2", "CYPHER 3.3" ).forEach( version ->
{
db().execute( "CREATE INDEX ON :Person(name)" );
db().execute( "Call db.awaitIndexes()" );

assertNotifications( version + "EXPLAIN MATCH (n:Person:Foo) WHERE n['key-' + n.name] = 'value' RETURN n",
containsItem( dynamicPropertyWarning ) );
} );
}

@Test
public void shouldWarnOnUnfulfillableIndexSeekUsingDynamicPropertyAndMultipleIndexedLabels() throws Exception
{ {
Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version ->
{ {
Expand Down Expand Up @@ -637,6 +660,20 @@ public void shouldWarnOnMissingLabel() throws Exception
assertNotifications( "EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( unknownLabelWarning ) ); assertNotifications( "EXPLAIN MATCH (a:NO_SUCH_THING) RETURN a", containsItem( unknownLabelWarning ) );
} }


@Test
public void shouldWarnOnMisspelledLabel() throws Exception {
try ( Transaction tx = db().beginTx() )
{
db().createNode().addLabel( label( "Person" ) );
tx.success();
}

Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> {
assertNotifications(version +"EXPLAIN MATCH (n:Preson) RETURN *", containsItem( unknownLabelWarning ) );
shouldNotNotifyInStream( version, "EXPLAIN MATCH (n:Person) RETURN *" );
});
}

@Test @Test
public void shouldWarnOnMissingLabelWithCommentInBeginningWithOlderCypherVersions() throws Exception public void shouldWarnOnMissingLabelWithCommentInBeginningWithOlderCypherVersions() throws Exception
{ {
Expand Down Expand Up @@ -679,13 +716,28 @@ public void shouldNotNotifyForMissingLabelOnUpdate() throws Exception
@Test @Test
public void shouldWarnOnMissingRelationshipType() throws Exception public void shouldWarnOnMissingRelationshipType() throws Exception
{ {
assertNotifications( "EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( unknownRelatonshipWarning ) ); assertNotifications( "EXPLAIN MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( unknownRelationshipWarning ) );
}

@Test
public void shouldWarnOnMisspelledRelationship() throws Exception {
try ( Transaction tx = db().beginTx() )
{
db().createNode().addLabel( label( "Person" ) );
tx.success();
}

Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> {
db().execute( "CREATE (n)-[r:R]->(m)");
assertNotifications(version + "EXPLAIN MATCH ()-[r:r]->() RETURN *", containsItem( unknownRelationshipWarning ) );
shouldNotNotifyInStream( version, "EXPLAIN MATCH ()-[r:R]->() RETURN *" );
});
} }


@Test @Test
public void shouldWarnOnMissingRelationshipTypeWithComment() throws Exception public void shouldWarnOnMissingRelationshipTypeWithComment() throws Exception
{ {
assertNotifications( "EXPLAIN /*Comment*/ MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( unknownRelatonshipWarning ) ); assertNotifications( "EXPLAIN /*Comment*/ MATCH ()-[a:NO_SUCH_THING]->() RETURN a", containsItem( unknownRelationshipWarning ) );
} }


@Test @Test
Expand All @@ -694,6 +746,23 @@ public void shouldWarnOnMissingProperty() throws Exception
assertNotifications( "EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( unknownPropertyKeyWarning ) ); assertNotifications( "EXPLAIN MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( unknownPropertyKeyWarning ) );
} }


@Test
public void shouldWarnOnMisspelledProperty() throws Exception {
db().execute("CREATE (n {prop : 42})");

Stream.of( "CYPHER 2.3", "CYPHER 3.1", "CYPHER 3.2", "CYPHER 3.3" ).forEach( version -> {
db().execute( "CREATE (n)-[r:R]->(m)");
assertNotifications(version + "EXPLAIN MATCH (n) WHERE n.propp = 43 RETURN n", containsItem( unknownPropertyKeyWarning ) );
shouldNotNotifyInStream( version, "EXPLAIN MATCH (n) WHERE n.prop = 43 RETURN n" );
});
}

@Test
public void shouldWarnOnMissingPropertyWithComment() throws Exception
{
assertNotifications( "EXPLAIN /*Comment*/ MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( unknownPropertyKeyWarning ) );
}

@Test @Test
public void shouldNotNotifyForMissingPropertiesOnUpdate() throws Exception public void shouldNotNotifyForMissingPropertiesOnUpdate() throws Exception
{ {
Expand Down Expand Up @@ -778,9 +847,9 @@ public void shouldWarnThatStartIsDeprecatedForRelIndexSearch()
} }


@Test @Test
public void shouldWarnOnMissingPropertyWithComment() throws Exception public void version2_3ShouldWarnAboutBareNodes() throws Exception {
{ Result res = db().execute("EXPLAIN CYPHER 2.3 MATCH n RETURN n");
assertNotifications( "EXPLAIN /*Comment*/ MATCH (a {NO_SUCH_THING: 1337}) RETURN a", containsItem( unknownPropertyKeyWarning ) ); assert res.getNotifications().iterator().hasNext();
} }


private void assertNotifications( String query, Matcher<Iterable<Notification>> matchesExpectation ) private void assertNotifications( String query, Matcher<Iterable<Notification>> matchesExpectation )
Expand Down Expand Up @@ -987,7 +1056,7 @@ public Stream<ChangedResults> changedProc()
notification( "Neo.ClientNotification.Statement.UnknownPropertyKeyWarning", containsString( "the missing property name is" ), notification( "Neo.ClientNotification.Statement.UnknownPropertyKeyWarning", containsString( "the missing property name is" ),
any( InputPosition.class ), SeverityLevel.WARNING ); any( InputPosition.class ), SeverityLevel.WARNING );


private Matcher<Notification> unknownRelatonshipWarning = private Matcher<Notification> unknownRelationshipWarning =
notification( "Neo.ClientNotification.Statement.UnknownRelationshipTypeWarning", containsString( "the missing relationship type is" ), notification( "Neo.ClientNotification.Statement.UnknownRelationshipTypeWarning", containsString( "the missing relationship type is" ),
any( InputPosition.class ), SeverityLevel.WARNING ); any( InputPosition.class ), SeverityLevel.WARNING );


Expand Down

0 comments on commit b4dde89

Please sign in to comment.