Search in sources :

Example 1 with DefaultMigrationReport

use of com.mulesoft.tools.migration.report.DefaultMigrationReport in project mule-migration-assistant by mulesoft.

the class MigrationRunner method run.

public static int run(String[] args) throws Exception {
    Stopwatch stopwatch = Stopwatch.createStarted();
    Optional<MigrationRunner> migrationRunner = buildRunner(args);
    if (!migrationRunner.isPresent()) {
        return -1;
    }
    MigrationJob job = migrationRunner.get().buildMigrationJob();
    try {
        DefaultMigrationReport report = new DefaultMigrationReport();
        log("Executing migrator " + job.getRunnerVersion() + "...");
        job.execute(report);
        printMigrationSummary(job.getReportPath().resolve(REPORT_HOME).toAbsolutePath().toString(), stopwatch.stop().elapsed(MILLISECONDS), report);
        return 0;
    } catch (Exception ex) {
        printMigrationError(ex, stopwatch.stop().elapsed(MILLISECONDS));
        return -1;
    }
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) Stopwatch(com.google.common.base.Stopwatch) MigrationJob(com.mulesoft.tools.migration.engine.MigrationJob) ConsoleOptionsException(com.mulesoft.tools.migration.exception.ConsoleOptionsException)

Example 2 with DefaultMigrationReport

use of com.mulesoft.tools.migration.report.DefaultMigrationReport in project mule-migration-assistant by mulesoft.

the class MigrationJobTest method executeWithEmptyTaskList.

@Test
public void executeWithEmptyTaskList() throws Exception {
    migrationJob = new MigrationJob.MigrationJobBuilder().withProject(originalProjectPath).withOutputProject(migratedProjectPath).withInputVersion(MULE_370_VERSION).withOuputVersion(MULE_413_VERSION).build();
    migrationJob.execute(new DefaultMigrationReport());
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) Test(org.junit.Test)

Example 3 with DefaultMigrationReport

use of com.mulesoft.tools.migration.report.DefaultMigrationReport in project mule-migration-assistant by mulesoft.

the class MigrationJobTest method execute_assertContentGitIgnoreFile.

@Test
public void execute_assertContentGitIgnoreFile() throws Exception {
    migrationJob = new MigrationJob.MigrationJobBuilder().withProject(originalProjectPath).withOutputProject(migratedProjectPath).withInputVersion(MULE_370_VERSION).withOuputVersion(MULE_413_VERSION).build();
    migrationJob.execute(new DefaultMigrationReport());
    File gitIgnore = new File(migratedProjectPath.toFile(), ".gitignore");
    InputStream gitignoreResourceStream = getClass().getClassLoader().getResourceAsStream("gitignore-maven-template");
    byte[] sourceBytes = IOUtils.toByteArray(gitignoreResourceStream);
    byte[] targetBytes = FileUtils.readFileToByteArray(gitIgnore);
    assertArrayEquals(sourceBytes, targetBytes);
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) InputStream(java.io.InputStream) File(java.io.File) Test(org.junit.Test)

Example 4 with DefaultMigrationReport

use of com.mulesoft.tools.migration.report.DefaultMigrationReport in project mule-migration-assistant by mulesoft.

the class MigrationJobTest method executeWithTaskThatFailsAndStopExecution.

@Test(expected = MigrationTaskException.class)
public void executeWithTaskThatFailsAndStopExecution() throws Exception {
    migrationJob = new MigrationJob.MigrationJobBuilder().withProject(originalProjectPath).withOutputProject(migratedProjectPath).withInputVersion(MULE_380_VERSION).withOuputVersion(MULE_413_VERSION).withCancelOnError(true).build();
    AbstractMigrationTask migrationTask = mock(AbstractMigrationTask.class);
    doThrow(MigrationTaskException.class).when(migrationTask).execute(any(MigrationReport.class));
    when(migrationTask.getApplicableProjectTypes()).thenReturn(singleton(MULE_FOUR_APPLICATION));
    migrationTasks.add(migrationTask);
    Whitebox.setInternalState(migrationJob, "migrationTasks", migrationTasks);
    migrationJob.execute(new DefaultMigrationReport());
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Test(org.junit.Test)

Example 5 with DefaultMigrationReport

use of com.mulesoft.tools.migration.report.DefaultMigrationReport in project mule-migration-assistant by mulesoft.

the class MigrationJobTest method execute_assertGitIgnoreFile.

@Test
public void execute_assertGitIgnoreFile() throws Exception {
    migrationJob = new MigrationJob.MigrationJobBuilder().withProject(originalProjectPath).withOutputProject(migratedProjectPath).withInputVersion(MULE_370_VERSION).withOuputVersion(MULE_413_VERSION).build();
    migrationJob.execute(new DefaultMigrationReport());
    File gitIgnore = new File(migratedProjectPath.toFile(), ".gitignore");
    assertTrue(gitIgnore.exists());
}
Also used : DefaultMigrationReport(com.mulesoft.tools.migration.report.DefaultMigrationReport) File(java.io.File) Test(org.junit.Test)

Aggregations

DefaultMigrationReport (com.mulesoft.tools.migration.report.DefaultMigrationReport)9 Test (org.junit.Test)7 MunitMigrationTask (com.mulesoft.tools.migration.library.munit.tasks.MunitMigrationTask)2 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)2 AbstractMigrationTask (com.mulesoft.tools.migration.task.AbstractMigrationTask)2 File (java.io.File)2 Stopwatch (com.google.common.base.Stopwatch)1 MigrationJob (com.mulesoft.tools.migration.engine.MigrationJob)1 ConsoleOptionsException (com.mulesoft.tools.migration.exception.ConsoleOptionsException)1 InputStream (java.io.InputStream)1