Search in sources :

Example 1 with SetPropertyMigrationStep

use of com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep in project mule-migration-assistant by mulesoft.

the class SetPropertyMigrationStepTestCase method doubleSetPropertyElementWithSetResponse.

@Test
public void doubleSetPropertyElementWithSetResponse() {
    SetPropertyMigrationStep step = new SetPropertyMigrationStep();
    step.setApplicationModel(appModel);
    Element firstSetPropertyElement = getTestElement();
    Element secondSetPropertyElement = getTestElement();
    Element rootElement = setDocument(firstSetPropertyElement, secondSetPropertyElement, getSetResponseElement());
    step.execute(firstSetPropertyElement, reportMock);
    step.execute(secondSetPropertyElement, reportMock);
    assertTestElementIsNotModified(firstSetPropertyElement);
    assertTestElementIsNotModified(secondSetPropertyElement);
    assertThat(rootElement.getContentSize(), is(4));
    assertThat(((Element) rootElement.getContent(0)).getName(), is(SET_PROPERTY_TAG_NAME));
    assertThat(((Element) rootElement.getContent(1)).getName(), is(SET_PROPERTY_TAG_NAME));
    assertOutboundPropertiesToVarElement((Element) rootElement.getContent(2));
    assertSetResponseElement((Element) rootElement.getContent(3));
}
Also used : Element(org.jdom2.Element) SetPropertyMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep) Test(org.junit.Test)

Example 2 with SetPropertyMigrationStep

use of com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep in project mule-migration-assistant by mulesoft.

the class SetPropertyMigrationStepTestCase method singleSetPropertyElementWithSetResponse.

@Test
public void singleSetPropertyElementWithSetResponse() {
    SetPropertyMigrationStep step = new SetPropertyMigrationStep();
    step.setApplicationModel(appModel);
    Element element = getTestElement();
    Element rootElement = setDocument(element, getSetResponseElement());
    step.execute(element, reportMock);
    assertTestElementIsNotModified(element);
    assertThat(rootElement.getContentSize(), is(3));
    assertThat(((Element) rootElement.getContent(0)).getName(), is(SET_PROPERTY_TAG_NAME));
    assertOutboundPropertiesToVarElement((Element) rootElement.getContent(1));
    assertSetResponseElement((Element) rootElement.getContent(2));
}
Also used : Element(org.jdom2.Element) SetPropertyMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep) Test(org.junit.Test)

Example 3 with SetPropertyMigrationStep

use of com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep in project mule-migration-assistant by mulesoft.

the class SetPropertyMigrationStepTestCase method singleSetPropertyElement.

@Test
public void singleSetPropertyElement() {
    SetPropertyMigrationStep step = new SetPropertyMigrationStep();
    step.setApplicationModel(appModel);
    Element element = getTestElement();
    Element rootElement = setDocument(element);
    step.execute(element, reportMock);
    assertTestElementIsNotModified(element);
    assertThat(rootElement.getContentSize(), is(3));
    assertThat(((Element) rootElement.getContent(0)).getName(), is(SET_PROPERTY_TAG_NAME));
    assertOutboundPropertiesToVarElement((Element) rootElement.getContent(1));
    assertSetResponseElement((Element) rootElement.getContent(2));
}
Also used : Element(org.jdom2.Element) SetPropertyMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep) Test(org.junit.Test)

Example 4 with SetPropertyMigrationStep

use of com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep in project mule-migration-assistant by mulesoft.

the class SetPropertyMigrationStepTestCase method pomContributionsInSetPropertyTest.

@Test
public void pomContributionsInSetPropertyTest() {
    SetPropertyMigrationStep step = new SetPropertyMigrationStep();
    step.setApplicationModel(appModel);
    Element element = appModel.getNodes(XPATH_NODE_EXPRESSION).get(0);
    step.execute(element, reportMock);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(1));
    Dependency httpPolicyTransformExtension = pm.getDependencies().get(0);
    assertThat(httpPolicyTransformExtension.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpPolicyTransformExtension.getArtifactId(), is(MULE_HTTP_POLICY_TRANSFORM_EXTENSION_ARTIFACT_ID));
    assertThat(httpPolicyTransformExtension.getVersion(), is(notNullValue()));
    assertThat(httpPolicyTransformExtension.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : Element(org.jdom2.Element) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) SetPropertyMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 5 with SetPropertyMigrationStep

use of com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep in project mule-migration-assistant by mulesoft.

the class SetPropertyMigrationStepTestCase method nestedSetPropertyElement.

@Test
public void nestedSetPropertyElement() {
    SetPropertyMigrationStep step = new SetPropertyMigrationStep();
    step.setApplicationModel(appModel);
    Element firstSetPropertyElement = getTestElement();
    Element secondSetPropertyElement = getTestElement();
    Element genericElement = new Element(GENERIC_TAG_NAME, MULE_4_POLICY_NAMESPACE).addContent(secondSetPropertyElement);
    Element rootElement = setDocument(firstSetPropertyElement, genericElement);
    step.execute(firstSetPropertyElement, reportMock);
    performNestedElementTestsAssertions(rootElement, 4, 2, 3, 1, 1);
    step.execute(secondSetPropertyElement, reportMock);
    performNestedElementTestsAssertions(rootElement, 4, 2, 3, 1, 3);
}
Also used : Element(org.jdom2.Element) SetPropertyMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep) Test(org.junit.Test)

Aggregations

SetPropertyMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep)9 Element (org.jdom2.Element)8 Test (org.junit.Test)8 Dependency (com.mulesoft.tools.migration.project.model.pom.Dependency)1 PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)1