use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method emptyDbTaskWithDependency.
@Test
public void emptyDbTaskWithDependency() throws Exception {
// create empty db to avoid problems on Java 11
prepareDerbyDatabase("empty_db");
GradleRunner runner = createRunner("dbimport-with-project-dependency", "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."));
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method excludeRelDbTaskSuccess.
@Test
public void excludeRelDbTaskSuccess() throws Exception {
String dbUrl = prepareDerbyDatabase("exclude_Table");
File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
assertFalse(dataMap.exists());
GradleRunner runner = createRunner("dbimport_excludeRel", "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: SCHEMA_01.TEST1"));
assertTrue(result.getOutput().contains("Table: SCHEMA_01.TEST2"));
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class CgenTaskIT method cgenWithConfigInDm.
@Test
public void cgenWithConfigInDm() throws Exception {
GradleRunner runner = createRunner("cgen_with_config", "cgen", "-PdataMap=cgen_with_config.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory1/";
String generatedClassPath = generatedDirectoryPath + "ObjEntity1.txt";
String datamap = generatedDirectoryPath + "CgenMap.txt";
String notIncludedEntity = generatedDirectoryPath + "ObjEntity.txt";
String notIncludedEmbeddable = generatedDirectoryPath + "Embeddable.txt";
Path generatedClass = Paths.get(generatedClassPath);
Path generatedDataMap = Paths.get(datamap);
Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
Path generatedNotIncludedEmbeddable = Paths.get(notIncludedEmbeddable);
assertTrue(Files.exists(generatedClass));
assertFalse(Files.exists(generatedDataMap));
assertFalse(Files.exists(generatedNotIncludedEmbeddable));
assertFalse(Files.exists(generatedNotIncludedEntity));
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class CgenTaskIT method testReplaceDatamapMode.
@Test
public void testReplaceDatamapMode() throws Exception {
GradleRunner runner = createRunner("cgen_replaceDatamapMode", "cgen", "-PdataMap=cgenMap.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/";
String notIncludedEntity = generatedDirectoryPath + "ObjEntity.txt";
Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
assertFalse(Files.exists(generatedNotIncludedEntity));
String notIncludedEntity1 = generatedDirectoryPath + "ObjEntity1.txt";
Path generatedNotIncludedEntity1 = Paths.get(notIncludedEntity1);
assertFalse(Files.exists(generatedNotIncludedEntity1));
String notIncludedEmbeddable = generatedDirectoryPath + "Embeddable.txt";
Path generatedNotIncludedEmbeddable = Paths.get(notIncludedEmbeddable);
assertFalse(Files.exists(generatedNotIncludedEmbeddable));
String includedDataMap = generatedDirectoryPath + "CgenMap.txt";
Path generatedIncludedDataMap = Paths.get(includedDataMap);
assertTrue(Files.exists(generatedIncludedDataMap));
String includedSuperDataMap = generatedDirectoryPath + "auto/_CgenMap.txt";
Path generatedIncludedSuperDataMap = Paths.get(includedSuperDataMap);
assertTrue(Files.exists(generatedIncludedSuperDataMap));
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.GradleRunner in project liferay-blade-samples by liferay.
the class GradleRunnerUtil method executeGradleRunner.
public static BuildTask executeGradleRunner(File projectDir, String... taskPath) {
GradleRunner runner = GradleRunner.create().withProjectDir(projectDir);
GradleRunner runnerWithArguments = runner.withArguments(taskPath);
BuildResult buildResult = runnerWithArguments.build();
BuildTask buildtask = null;
for (BuildTask task : buildResult.getTasks()) {
if (task.getPath().endsWith(taskPath[taskPath.length - 1])) {
buildtask = task;
break;
}
}
return buildtask;
}
Aggregations