use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class CgenTaskIT method classGeneratingWithCustomConfigSuccess.
@Test
public void classGeneratingWithCustomConfigSuccess() throws Exception {
GradleRunner runner = createRunner("cgen_custom_config", "cgen", "-PdataMap=test_datamap.map.xml");
BuildResult result = runner.build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/org/example/cayenne/persistent/";
String generatedClassPath = generatedDirectoryPath + "City.groovy";
String excludedClassPath = generatedDirectoryPath + "Artist.groovy";
String generatedParentClassPath = generatedDirectoryPath + "auto/_City.groovy";
String excludedParentClassPath = generatedDirectoryPath + "auto/_Artist.groovy";
File generatedClass = new File(generatedClassPath);
File excludedClass = new File(excludedClassPath);
File generatedParentClass = new File(generatedParentClassPath);
File excludedParentClass = new File(excludedParentClassPath);
assertTrue(generatedClass.exists());
assertTrue(!excludedClass.exists());
assertTrue(!excludedParentClass.exists());
assertTrue(!generatedParentClass.exists());
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class CgenTaskIT method testWithConfigsInDmAndPom.
@Test
public void testWithConfigsInDmAndPom() throws Exception {
GradleRunner runner = createRunner("cgen_with_configs", "cgen", "-PdataMap=cgenMap.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/";
String generatedClassPath = generatedDirectoryPath + "ObjEntity.groovy";
Path generatedClass = Paths.get(generatedClassPath);
assertTrue(Files.exists(generatedClass));
String notIncludedEntity = generatedDirectoryPath + "ObjEntity1.groovy";
Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
assertFalse(Files.exists(generatedNotIncludedEntity));
String includedDataMap = generatedDirectoryPath + "CgenMap.groovy";
Path generatedIncludedDataMap = Paths.get(includedDataMap);
assertTrue(Files.exists(generatedIncludedDataMap));
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class CgenTaskIT method classGeneratingWithDefaultConfigSuccess.
@Test
public void classGeneratingWithDefaultConfigSuccess() throws Exception {
GradleRunner runner = createRunner("cgen_default_config", "cgen", "-PdataMap=test_datamap.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/src/main/java/org/example/cayenne/persistent/";
String generatedClassPath = generatedDirectoryPath + "City.java";
String generatedParentClassPath = generatedDirectoryPath + "auto/_City.java";
File generatedClass = new File(generatedClassPath);
File generatedParentClass = new File(generatedParentClassPath);
assertTrue(generatedClass.exists());
assertTrue(generatedParentClass.exists());
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.BuildResult in project cayenne by apache.
the class DbImportIT method notConfiguredTaskFailure.
@Test
public void notConfiguredTaskFailure() throws Exception {
GradleRunner runner = createRunner("dbimport_failure", "cdbimport", "--info");
BuildResult result = runner.buildAndFail();
// new version of Gradle (4.3.1 as of 05/12/2017) seems not return task status, so ignore this
// assertNotNull(result.task(":cdbimport"));
// assertEquals(TaskOutcome.FAILED, result.task(":cdbimport").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 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."));
}
Aggregations