Search in sources :

Example 1 with Parent

use of com.mulesoft.tools.migration.project.model.pom.Parent in project mule-migration-assistant by mulesoft.

the class UpdateProjectParentTest method executeWithGavAndParent.

@Test
public void executeWithGavAndParent() throws URISyntaxException, IOException, XmlPullParserException {
    UpdateProjectParent updateProjectParent = new UpdateProjectParent();
    final ApplicationModel applicationModelMock = mock(ApplicationModel.class);
    Parent parent = new Parent.ParentBuilder().withGroupId("com.mule").withArtifactId("rest-parent").withVersion("2.0.0").build();
    when(applicationModelMock.getProjectPomParent()).thenReturn(Optional.of(parent));
    updateProjectParent.setApplicationModel(applicationModelMock);
    Path pomPath = Paths.get(getClass().getResource(PARENT_POM).toURI());
    PomModel model = new PomModel.PomModelBuilder().withPom(pomPath).build();
    parent = model.getParent().get();
    assertEquals(parent.getGroupId(), "com.mule.parent");
    assertEquals(parent.getArtifactId(), "parent-rest");
    assertEquals(parent.getVersion(), "1.0.0");
    try {
        updateProjectParent.execute(model, report.getReport());
        Parent afterParent = model.getParent().get();
        assertEquals(afterParent.getGroupId(), "com.mule");
        assertEquals(afterParent.getArtifactId(), "rest-parent");
        assertEquals(afterParent.getVersion(), "2.0.0");
    } catch (RuntimeException e) {
        fail("no exception have to be thrown");
    }
}
Also used : Path(java.nio.file.Path) Parent(com.mulesoft.tools.migration.project.model.pom.Parent) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Example 2 with Parent

use of com.mulesoft.tools.migration.project.model.pom.Parent in project mule-migration-assistant by mulesoft.

the class UpdateProjectParentTest method executeWithProjectParentGavAndWithoutParent.

@Test
public void executeWithProjectParentGavAndWithoutParent() throws URISyntaxException, IOException, XmlPullParserException {
    UpdateProjectParent updateProjectParent = new UpdateProjectParent();
    final ApplicationModel applicationModelMock = mock(ApplicationModel.class);
    Parent parent = new Parent.ParentBuilder().withGroupId("com.mule").withArtifactId("rest-parent").withVersion("2.0.0").build();
    when(applicationModelMock.getProjectPomParent()).thenReturn(Optional.of(parent));
    updateProjectParent.setApplicationModel(applicationModelMock);
    Path pomPath = Paths.get(getClass().getResource(POM).toURI());
    PomModel model = new PomModel.PomModelBuilder().withPom(pomPath).build();
    try {
        updateProjectParent.execute(model, report.getReport());
        assertTrue(!model.getParent().isPresent());
    } catch (RuntimeException e) {
        fail("no exception have to be thrown");
    }
}
Also used : Path(java.nio.file.Path) Parent(com.mulesoft.tools.migration.project.model.pom.Parent) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) Test(org.junit.Test)

Aggregations

ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)2 Parent (com.mulesoft.tools.migration.project.model.pom.Parent)2 PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)2 Path (java.nio.file.Path)2 Test (org.junit.Test)2