Skip to content

Commit a9bb784

Browse files
author
Florent Biville
committed
[#35] Relocate procedure source files
Procedure source file for the processor unit tests are now in the standard test source file location, thus being considered as plain old Java files. test-jar packaging has been therefore simplified and filters out invalid procedures.
1 parent 296f165 commit a9bb784

File tree

27 files changed

+160
-117
lines changed

27 files changed

+160
-117
lines changed

integration-tests/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45

integration-tests/src/test/java/net/biville/florent/sproccompiler/ProcedureTest.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package net.biville.florent.sproccompiler;
1717

18+
import net.biville.florent.sproccompiler.procedures.valid.Procedures;
1819
import org.junit.Rule;
1920
import org.junit.Test;
20-
import test_classes.working_procedures.Procedures;
2121

2222
import org.neo4j.driver.v1.Config;
2323
import org.neo4j.driver.v1.Driver;
@@ -32,9 +32,11 @@
3232
public class ProcedureTest
3333
{
3434

35-
@Rule
36-
public Neo4jRule graphDb = new Neo4jRule().withProcedure( Procedures.class );
35+
private static final Class<?> PROCEDURES_CLASS = Procedures.class;
3736

37+
@Rule
38+
public Neo4jRule graphDb = new Neo4jRule().withProcedure( PROCEDURES_CLASS );
39+
private String procedureNamespace = PROCEDURES_CLASS.getPackage().getName();
3840

3941
@Test
4042
public void calls_simplistic_procedure()
@@ -43,7 +45,7 @@ public void calls_simplistic_procedure()
4345
Session session = driver.session() )
4446
{
4547

46-
StatementResult result = session.run( "CALL test_classes.working_procedures.theAnswer()" );
48+
StatementResult result = session.run( "CALL " + procedureNamespace + ".theAnswer()" );
4749

4850
assertThat( result.single().get( "value" ).asLong() ).isEqualTo( 42L );
4951
}
@@ -56,17 +58,17 @@ public void calls_procedures_with_simple_input_type_returning_void()
5658
Session session = driver.session() )
5759
{
5860

59-
session.run( "CALL test_classes.working_procedures.simpleInput00()" );
60-
session.run( "CALL test_classes.working_procedures.simpleInput01('string')" );
61-
session.run( "CALL test_classes.working_procedures.simpleInput02(42)" );
62-
session.run( "CALL test_classes.working_procedures.simpleInput03(42)" );
63-
session.run( "CALL test_classes.working_procedures.simpleInput04(4.2)" );
64-
session.run( "CALL test_classes.working_procedures.simpleInput05(true)" );
65-
session.run( "CALL test_classes.working_procedures.simpleInput06(false)" );
66-
session.run( "CALL test_classes.working_procedures.simpleInput07({foo:'bar'})" );
67-
session.run( "MATCH (n) CALL test_classes.working_procedures.simpleInput08(n) RETURN n" );
68-
session.run( "MATCH p=(()-[r]->()) CALL test_classes.working_procedures.simpleInput09(p) RETURN p" );
69-
session.run( "MATCH ()-[r]->() CALL test_classes.working_procedures.simpleInput10(r) RETURN r" );
61+
session.run( "CALL " + procedureNamespace + ".simpleInput00()" );
62+
session.run( "CALL " + procedureNamespace + ".simpleInput01('string')" );
63+
session.run( "CALL " + procedureNamespace + ".simpleInput02(42)" );
64+
session.run( "CALL " + procedureNamespace + ".simpleInput03(42)" );
65+
session.run( "CALL " + procedureNamespace + ".simpleInput04(4.2)" );
66+
session.run( "CALL " + procedureNamespace + ".simpleInput05(true)" );
67+
session.run( "CALL " + procedureNamespace + ".simpleInput06(false)" );
68+
session.run( "CALL " + procedureNamespace + ".simpleInput07({foo:'bar'})" );
69+
session.run( "MATCH (n) CALL " + procedureNamespace + ".simpleInput08(n) RETURN n" );
70+
session.run( "MATCH p=(()-[r]->()) CALL " + procedureNamespace + ".simpleInput09(p) RETURN p" );
71+
session.run( "MATCH ()-[r]->() CALL " + procedureNamespace + ".simpleInput10(r) RETURN r" );
7072
}
7173
}
7274

@@ -77,21 +79,15 @@ public void calls_procedures_with_simple_input_type_returning_record_with_primit
7779
Session session = driver.session() )
7880
{
7981

80-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput11('string')" ).single() )
81-
.isNotNull();
82-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput12(42)" ).single() ).isNotNull();
83-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput13(42)" ).single() ).isNotNull();
84-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput14(4.2)" ).single() ).isNotNull();
85-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput15(true)" ).single() )
86-
.isNotNull();
87-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput16(false)" ).single() )
88-
.isNotNull();
89-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput17({foo:'bar'})" ).single() )
82+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput11('string')" ).single() ).isNotNull();
83+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput12(42)" ).single() ).isNotNull();
84+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput13(42)" ).single() ).isNotNull();
85+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput14(4.2)" ).single() ).isNotNull();
86+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput15(true)" ).single() ).isNotNull();
87+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput16(false)" ).single() ).isNotNull();
88+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput17({foo:'bar'})" ).single() )
9089
.isNotNull();
91-
// assertThat(session.run("MATCH (n) CALL test_classes.working_procedures.simpleInput18(n) YIELD field01 RETURN *").single()).isNotNull();
92-
// assertThat(session.run("MATCH p=(()-[r]->()) CALL test_classes.working_procedures.simpleInput19(p) YIELD field01 RETURN *").single()).isNotNull();
93-
// assertThat(session.run("MATCH ()-[r]->() CALL test_classes.working_procedures.simpleInput20(r) YIELD field01 RETURN *").single()).isNotNull();
94-
assertThat( session.run( "CALL test_classes.working_procedures.simpleInput21()" ).single() ).isNotNull();
90+
assertThat( session.run( "CALL " + procedureNamespace + ".simpleInput21()" ).single() ).isNotNull();
9591
}
9692

9793
}

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<groupId>net.biville.florent</groupId>

processor/pom.xml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<parent>
@@ -45,6 +46,12 @@
4546
</dependencies>
4647

4748
<build>
49+
<testResources>
50+
<testResource>
51+
<directory>src/test/resources</directory>
52+
<filtering>true</filtering>
53+
</testResource>
54+
</testResources>
4855
<plugins>
4956
<plugin>
5057
<artifactId>maven-source-plugin</artifactId>
@@ -61,24 +68,6 @@
6168
</annotationProcessors>
6269
</configuration>
6370
</plugin>
64-
<plugin>
65-
<groupId>org.codehaus.mojo</groupId>
66-
<artifactId>build-helper-maven-plugin</artifactId>
67-
<version>1.10</version>
68-
<executions>
69-
<execution>
70-
<id>add-custom-test-sources</id>
71-
<goals>
72-
<goal>add-test-source</goal>
73-
</goals>
74-
<configuration>
75-
<sources>
76-
<source>${project.basedir}/src/test/resources/test_classes/working_procedures</source>
77-
</sources>
78-
</configuration>
79-
</execution>
80-
</executions>
81-
</plugin>
8271
<plugin>
8372
<artifactId>maven-jar-plugin</artifactId>
8473
<version>3.0.1</version>
@@ -89,7 +78,7 @@
8978
</goals>
9079
<configuration>
9180
<includes>
92-
<include>**/working_procedures/**</include>
81+
<include>net/biville/florent/sproccompiler/procedures/valid/**/*</include>
9382
</includes>
9483
</configuration>
9584
</execution>

processor/src/main/java/net/biville/florent/sproccompiler/StoredProcedureProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public synchronized void init( ProcessingEnvironment processingEnv )
8383

8484
visitedProcedures.clear();
8585
messagePrinter = new MessagePrinter( processingEnv.getMessager() );
86-
storedProcedureVisitor = new StoredProcedureVisitor( typeUtils, elementUtils, processingEnv.getOptions().containsKey(
87-
IGNORE_CONTEXT_WARNINGS ) );
86+
storedProcedureVisitor = new StoredProcedureVisitor( typeUtils, elementUtils,
87+
processingEnv.getOptions().containsKey( IGNORE_CONTEXT_WARNINGS ) );
8888
duplicateProcedure = new DuplicatedStoredProcedureValidator( typeUtils, elementUtils );
8989
}
9090

0 commit comments

Comments
 (0)