Search in sources :

Example 6 with GradleRunner

use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.

the class DbImportIT method emptyDbTaskSuccess.

@Test
public void emptyDbTaskSuccess() throws Exception {
    // create empty db to avoid problems on Java 11
    prepareDerbyDatabase("empty_db");
    GradleRunner runner = createRunner("dbimport_empty_db", "cdbimport", "--info");
    BuildResult result = runner.build();
    assertNotNull(result.task(":cdbimport"));
    assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
    File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
    assertTrue(dataMap.exists());
    assertTrue(result.getOutput().contains("Detected changes: No changes to import."));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) GradleRunner(org.gradle.testkit.runner.GradleRunner) File(java.io.File) Test(org.junit.Test)

Example 7 with GradleRunner

use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.

the class DbImportIT method simpleDbTaskSuccess.

@Test
public void simpleDbTaskSuccess() throws Exception {
    String dbUrl = prepareDerbyDatabase("test_map_db");
    File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
    assertFalse(dataMap.exists());
    GradleRunner runner = createRunner("dbimport_simple_db", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
    BuildResult result = runner.build();
    assertNotNull(result.task(":cdbimport"));
    assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
    assertTrue(dataMap.exists());
    // Check few lines from reverse engineering output
    assertTrue(result.getOutput().contains("Table: APP.PAINTING"));
    assertTrue(result.getOutput().contains("Db Relationship : toOne  (EXHIBIT.GALLERY_ID, GALLERY.GALLERY_ID)"));
    assertTrue(result.getOutput().contains("Db Relationship : toMany (GALLERY.GALLERY_ID, PAINTING.GALLERY_ID)"));
    assertTrue(result.getOutput().contains("Create Table         ARTIST"));
    assertFalse(result.getOutput().contains("Create Table         PAINTING1"));
    assertTrue(result.getOutput().contains("Skip relation: '.APP.ARTIST.ARTIST_ID <- .APP.PAINTING1.ARTIST_ID # 1'"));
    assertTrue(result.getOutput().contains("Migration Complete Successfully."));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) GradleRunner(org.gradle.testkit.runner.GradleRunner) File(java.io.File) Test(org.junit.Test)

Example 8 with GradleRunner

use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.

the class DbImportIT method withProjectTaskSuccess.

@Test
public void withProjectTaskSuccess() throws Exception {
    String dbUrl = prepareDerbyDatabase("test_project_db");
    File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
    assertFalse(dataMap.exists());
    File project = new File(projectDir.getAbsolutePath() + "/cayenne-project.xml");
    assertFalse(project.exists());
    GradleRunner runner = createRunner("dbimport_with_project", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
    BuildResult result = runner.build();
    assertNotNull(result.task(":cdbimport"));
    assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
    assertTrue(dataMap.isFile());
    assertTrue(project.isFile());
    // Check few lines from reverse engineering output
    assertTrue(result.getOutput().contains("Table: APP.PAINTING"));
    assertTrue(result.getOutput().contains("Db Relationship : toOne  (EXHIBIT.GALLERY_ID, GALLERY.GALLERY_ID)"));
    assertTrue(result.getOutput().contains("Db Relationship : toMany (GALLERY.GALLERY_ID, PAINTING.GALLERY_ID)"));
    assertTrue(result.getOutput().contains("Create Table         ARTIST"));
    assertFalse(result.getOutput().contains("Create Table         PAINTING1"));
    assertTrue(result.getOutput().contains("Skip relation: '.APP.ARTIST.ARTIST_ID <- .APP.PAINTING1.ARTIST_ID # 1'"));
    assertTrue(result.getOutput().contains("Migration Complete Successfully."));
}
Also used : BuildResult(org.gradle.testkit.runner.BuildResult) GradleRunner(org.gradle.testkit.runner.GradleRunner) File(java.io.File) Test(org.junit.Test)

Example 9 with GradleRunner

use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.

the class GradlePluginIT method testDbImportWithGradleVersion.

private void testDbImportWithGradleVersion(String version) throws Exception {
    String dbUrl = "jdbc:derby:" + projectDir.getAbsolutePath() + "/build/" + version.replace('.', '_');
    dbUrl += ";create=true";
    GradleRunner runner = createRunner("dbimport_simple_db", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
    runner.withGradleVersion(version);
    runner.build();
}
Also used : GradleRunner(org.gradle.testkit.runner.GradleRunner)

Example 10 with GradleRunner

use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.

the class GradlePluginIT method testCgenWithGradleVersion.

private void testCgenWithGradleVersion(String version) throws Exception {
    GradleRunner runner = createRunner("cgen_default_config", "cgen", "-PdataMap=test_datamap.map.xml");
    runner.withGradleVersion(version);
    runner.build();
}
Also used : GradleRunner(org.gradle.testkit.runner.GradleRunner)

Aggregations

GradleRunner (org.gradle.testkit.runner.GradleRunner)20 BuildResult (org.gradle.testkit.runner.BuildResult)17 Test (org.junit.Test)15 File (java.io.File)8 Path (java.nio.file.Path)3 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 JarFile (java.util.jar.JarFile)1 BuildTask (org.gradle.testkit.runner.BuildTask)1