use of org.gradle.testkit.runner.BuildResult 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."));
}
use of org.gradle.testkit.runner.BuildResult 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."));
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class DbGenerateTaskIT method notConfiguredTaskFailure.
@Test
public void notConfiguredTaskFailure() throws Exception {
GradleRunner runner = createRunner("cdbgen_failure", "cdbgen", "--info");
BuildResult result = runner.buildAndFail();
// NOTE: There will be no result for the task, as build will fail earlier because
// datamap is required parameter that is validated directly by Gradle before task execution.
// assertNotNull(result.task(":cdbgen"));
// assertEquals(TaskOutcome.FAILED, result.task(":cdbgen").getOutcome());
assertTrue(result.getOutput().contains("No datamap configured in task or in cayenne.defaultDataMap"));
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class DbGenerateTaskIT method defaultConfigTaskSuccess.
@Test
public void defaultConfigTaskSuccess() throws Exception {
String dbUrl = "jdbc:derby:build/testdb";
GradleRunner runner = createRunner("cdbgen_simple", "cdbgen", "-PdbUrl=" + dbUrl, "-PdataMap=test_datamap.map.xml", "--info");
BuildResult result = runner.build();
assertNotNull(result.task(":cdbgen"));
assertEquals(TaskOutcome.SUCCESS, result.task(":cdbgen").getOutcome());
assertTrue(result.getOutput().contains("generator options - [dropTables: false, dropPK: false, createTables: true, createPK: true, createFK: true]"));
/* // check that DB is really created
try (Connection connection = DriverManager.getConnection(dbUrl)) {
try (ResultSet rs = connection.getMetaData()
.getTables(null, null, "artist", new String[]{"TABLE"})) {
assertTrue(rs.next());
}
} */
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class DbGenerateTaskIT method customConfigTaskSuccess.
@Test
public void customConfigTaskSuccess() throws Exception {
GradleRunner runner = createRunner("cdbgen_custom", "customCdbgen", "-PdataMap=test_datamap.map.xml", "--info");
BuildResult result = runner.build();
assertNotNull(result.task(":customCdbgen"));
assertEquals(TaskOutcome.SUCCESS, result.task(":customCdbgen").getOutcome());
assertTrue(result.getOutput().contains("generator options - [dropTables: true, dropPK: true, createTables: false, createPK: false, createFK: false]"));
}
Aggregations