forked from liquibase/liquigraph
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Florent Biville
committed
May 10, 2016
1 parent
04a9e50
commit 1de95c6
Showing
13 changed files
with
477 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<properties> | ||
<jgiven.version>0.11.3</jgiven.version> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.liquigraph</groupId> | ||
<artifactId>liquigraph-parent</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>liquigraph-documentation</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.liquigraph</groupId> | ||
<artifactId>liquigraph-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.liquigraph</groupId> | ||
<artifactId>liquigraph-cli</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.liquigraph</groupId> | ||
<artifactId>liquigraph-maven-plugin</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.tngtech.jgiven</groupId> | ||
<artifactId>jgiven-junit</artifactId> | ||
<version>${jgiven.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.tngtech.jgiven</groupId> | ||
<artifactId>jgiven-maven-plugin</artifactId> | ||
<version>${jgiven.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>report</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<format>html</format> | ||
<outputDirectory>${project.build.directory}/documentation</outputDirectory> | ||
<title>Liquigraph documentation - Version ${project.version}</title> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<configuration> | ||
<appendAssemblyId>false</appendAssemblyId> | ||
<descriptor>src/assembly/assembly.xml</descriptor> | ||
<tarLongFileMode>posix</tarLongFileMode> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>create-archive</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> | ||
|
||
<id>doc</id> | ||
<formats> | ||
<format>zip</format> | ||
</formats> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/documentation</directory> | ||
<outputDirectory/> | ||
<includes> | ||
<include>*</include> | ||
</includes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
25 changes: 25 additions & 0 deletions
25
...documentation/src/test/java/org/liquigraph/core/documentation/ChangesetExecutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.documentation; | ||
|
||
/** | ||
* Created by f.biville on 10/05/2016. | ||
*/ | ||
public class ChangesetExecutionTest { | ||
|
||
//TODO: publish test-jar of Liquigraph-core | ||
//TODO: transactionality, run always, run on change | ||
} |
26 changes: 26 additions & 0 deletions
26
liquigraph-documentation/src/test/java/org/liquigraph/core/documentation/GettingStarted.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.documentation; | ||
|
||
import com.tngtech.jgiven.annotation.IsTag; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
|
||
@IsTag(description = "Core concepts of Liquigraph") | ||
@Retention( RetentionPolicy.RUNTIME ) | ||
public @interface GettingStarted { | ||
} |
144 changes: 144 additions & 0 deletions
144
...aph-documentation/src/test/java/org/liquigraph/core/documentation/GettingStartedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.documentation; | ||
|
||
import com.google.common.base.Charsets; | ||
import com.tngtech.jgiven.junit.SimpleScenarioTest; | ||
import org.junit.Test; | ||
import org.liquigraph.core.configuration.ConfigurationBuilder; | ||
import org.liquigraph.core.documentation.xml.XmlMarshaller; | ||
import org.liquigraph.core.model.Changeset; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import static java.nio.file.Files.readAllBytes; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class GettingStartedTest extends SimpleScenarioTest<GettingStartedTest.FundamentalsSteps> { | ||
|
||
@Test @GettingStarted | ||
public void _1_彡_a_changeset_is_a_migration_defined_in_Cypher() throws Exception { | ||
given().a_Cypher_migration("MATCH (n:Hello) SET n.contents = 'World' RETURN n"); | ||
|
||
when().defined_with_Liquigraph(); | ||
|
||
then().it_is_written_as_such( | ||
"<changeset author=\"author\" contexts=\"\" id=\"id\" run-always=\"false\" run-on-change=\"false\">\n" + | ||
" <query>MATCH (n:Hello) SET n.contents = 'World' RETURN n</query>\n" + | ||
"</changeset>"); | ||
} | ||
|
||
@Test @GettingStarted | ||
public void _2_彡_a_changeset_can_define_several_queries() throws Exception { | ||
given().several_Cypher_migrations( | ||
"MATCH (n:Bonjour) SET n.contents = 'Monde' RETURN n", | ||
"MATCH (n:Hello) SET n.contents = 'World' RETURN n" | ||
); | ||
|
||
when().defined_with_Liquigraph(); | ||
|
||
then().it_is_written_as_such( | ||
"<changeset author=\"author\" contexts=\"\" id=\"id\" run-always=\"false\" run-on-change=\"false\">\n" + | ||
" <query>MATCH (n:Bonjour) SET n.contents = 'Monde' RETURN n</query>\n" + | ||
" <query>MATCH (n:Hello) SET n.contents = 'World' RETURN n</query>\n" + | ||
"</changeset>"); | ||
} | ||
|
||
@Test @GettingStarted | ||
public void _3_彡_a_changelog_file_is_Liquigraph_entry_point_and_contains_changesets() throws Exception { | ||
given().a_changelog_file("getting_started/changelog.xml"); | ||
|
||
when().it_contains( | ||
"<changelog>\n" + | ||
" <changeset id=\"id\" author=\"author\">\n" + | ||
" <query>MATCH (n:Hello) SET n.contents = 'World' RETURN n</query>\n" + | ||
" </changeset>\n" + | ||
"</changelog>"); | ||
|
||
then().it_can_be_run_by_Liquigraph(); | ||
} | ||
|
||
//TODO: schema | ||
|
||
public static class FundamentalsSteps { | ||
|
||
private final XmlMarshaller marshaller = new XmlMarshaller(); | ||
private Collection<String> queries; | ||
private Changeset changeset; | ||
private String changelogPath; | ||
private File changelogFile; | ||
|
||
public FundamentalsSteps a_Cypher_migration(String query) { | ||
this.queries = Collections.singletonList(query); | ||
return this; | ||
} | ||
|
||
public FundamentalsSteps several_Cypher_migrations(String... queries) { | ||
this.queries = Arrays.asList(queries); | ||
return this; | ||
} | ||
|
||
public FundamentalsSteps defined_with_Liquigraph() { | ||
changeset = new Changeset(); | ||
changeset.setId("id"); | ||
changeset.setAuthor("author"); | ||
changeset.setQueries(queries); | ||
return this; | ||
} | ||
|
||
public void it_is_written_as_such(String expectedChangesetXml) throws Exception { | ||
String output = marshaller.serialize(changeset, "changeset", false); | ||
|
||
assertThat(output).isXmlEqualTo(expectedChangesetXml); | ||
} | ||
|
||
public void a_changelog_file(String changelogPath) throws URISyntaxException { | ||
this.changelogPath = changelogPath; | ||
} | ||
|
||
public void it_contains(String contents) throws URISyntaxException, IOException { | ||
changelogFile = new File(this.getClass().getResource("/" + changelogPath).toURI()); | ||
String fileContents = new String(readAllBytes(changelogFile.toPath()), Charsets.UTF_8); | ||
|
||
assertThat(fileContents).contains(contents); | ||
} | ||
|
||
public void it_can_be_run_by_Liquigraph() throws IOException { | ||
new ConfigurationBuilder() | ||
.withClassLoader(changelogClassloader()) | ||
.withMasterChangelogLocation(changelogPath) | ||
.withDryRunMode(Files.createTempDirectory("liquigraph-doc")) | ||
.withUsername("neo4j") | ||
.withPassword("secret") | ||
.withUri("jdbc:neo4j://localhost:7474") | ||
.build(); | ||
} | ||
|
||
private URLClassLoader changelogClassloader() throws MalformedURLException { | ||
return new URLClassLoader(new URL[]{changelogFile.toURI().toURL()}, this.getClass().getClassLoader()); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...raph-documentation/src/test/java/org/liquigraph/core/documentation/LiquigraphCliTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.documentation; | ||
|
||
/** | ||
* Created by f.biville on 10/05/2016. | ||
*/ | ||
public class LiquigraphCliTest { | ||
|
||
// TODO: run Liquigraph CLI (Unix, Windows) | ||
} |
24 changes: 24 additions & 0 deletions
24
...aph-documentation/src/test/java/org/liquigraph/core/documentation/LiquigraphCoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Copyright 2014-2016 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.liquigraph.core.documentation; | ||
|
||
/** | ||
* Created by f.biville on 10/05/2016. | ||
*/ | ||
public class LiquigraphCoreTest { | ||
|
||
// TODO: run Liquigraph core directly | ||
} |
Oops, something went wrong.