Search in sources :

Example 1 with NamespaceContribution

use of com.mulesoft.tools.migration.step.category.NamespaceContribution in project mule-migration-assistant by mulesoft.

the class AbstractMigrationTaskTest method executeWithFailedMigrationStep.

@Test(expected = MigrationTaskException.class)
public void executeWithFailedMigrationStep() throws Exception {
    NamespaceContribution namespaceContribution = mock(NamespaceContribution.class);
    doThrow(NullPointerException.class).when(namespaceContribution).execute(eq(applicationModelMock), any(MigrationReport.class));
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(namespaceContribution);
    migrationTask.setApplicationModel(applicationModelMock);
    ((MigrationTaskImpl) migrationTask).setMigrationSteps(steps);
    migrationTask.execute(mock(MigrationReport.class));
}
Also used : NamespaceContribution(com.mulesoft.tools.migration.step.category.NamespaceContribution) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Test(org.junit.Test)

Example 2 with NamespaceContribution

use of com.mulesoft.tools.migration.step.category.NamespaceContribution in project mule-migration-assistant by mulesoft.

the class AbstractMigrationTaskTest method execute.

@Test
public void execute() throws Exception {
    NamespaceContribution namespaceContributionMock = mock(NamespaceContribution.class);
    ApplicationModelContribution applicationModelContributionMock = mock(ApplicationModelContribution.class);
    ProjectStructureContribution projectStructureContributionMock = mock(ProjectStructureContribution.class);
    PomContribution pomContributionMock = mock(PomContribution.class);
    List<MigrationStep> steps = new ArrayList<>();
    steps.add(namespaceContributionMock);
    steps.add(applicationModelContributionMock);
    steps.add(projectStructureContributionMock);
    steps.add(pomContributionMock);
    InOrder inOrder = Mockito.inOrder(steps.toArray());
    migrationTask.setApplicationModel(applicationModelMock);
    ((MigrationTaskImpl) migrationTask).setMigrationSteps(new ArrayList<>(steps));
    migrationTask.execute(mock(MigrationReport.class));
    verify(namespaceContributionMock, times(1)).execute(any(ApplicationModel.class), any(MigrationReport.class));
    verify(applicationModelContributionMock, times(2)).getAppliedTo();
    verify(projectStructureContributionMock, times(1)).execute(isNull(), any(MigrationReport.class));
    verify(pomContributionMock, times(1)).execute(any(PomModel.class), any(MigrationReport.class));
    inOrder.verify(namespaceContributionMock).execute(any(ApplicationModel.class), any(MigrationReport.class));
    inOrder.verify(projectStructureContributionMock).execute(isNull(), any(MigrationReport.class));
    inOrder.verify(pomContributionMock).execute(any(PomModel.class), any(MigrationReport.class));
}
Also used : InOrder(org.mockito.InOrder) NamespaceContribution(com.mulesoft.tools.migration.step.category.NamespaceContribution) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PomContribution(com.mulesoft.tools.migration.step.category.PomContribution) ProjectStructureContribution(com.mulesoft.tools.migration.step.category.ProjectStructureContribution) ApplicationModelContribution(com.mulesoft.tools.migration.step.category.ApplicationModelContribution) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 MigrationStep (com.mulesoft.tools.migration.step.MigrationStep)2 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)2 NamespaceContribution (com.mulesoft.tools.migration.step.category.NamespaceContribution)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)1 PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)1 ApplicationModelContribution (com.mulesoft.tools.migration.step.category.ApplicationModelContribution)1 PomContribution (com.mulesoft.tools.migration.step.category.PomContribution)1 ProjectStructureContribution (com.mulesoft.tools.migration.step.category.ProjectStructureContribution)1 InOrder (org.mockito.InOrder)1