Search in sources :

Example 1 with LayoutModel

use of org.mule.runtime.api.meta.model.display.LayoutModel in project mule by mulesoft.

the class EnricherTestUtils method assertLayoutModel.

static void assertLayoutModel(String parameterName, int expectedOrder, Optional<LayoutModel> layoutModel) {
    assertThat(layoutModel.isPresent(), is(true));
    LayoutModel layoutModel1 = layoutModel.get();
    Integer order = layoutModel1.getOrder().orElse(null);
    assertThat("expecting parameter [" + parameterName + "] at position [" + expectedOrder + "] but was at [" + order + "]", order, is(expectedOrder));
}
Also used : LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel)

Example 2 with LayoutModel

use of org.mule.runtime.api.meta.model.display.LayoutModel in project mule by mulesoft.

the class ParameterGroupLayoutOrderTestCase method assertParameterOrder.

private void assertParameterOrder(ParameterizedModel parameterizedModel, String parameterName, int expectedOrder) {
    ParameterGroupModel paramOne = getNamedObject(parameterizedModel.getParameterGroupModels(), parameterName);
    Optional<LayoutModel> layoutModel = paramOne.getLayoutModel();
    assertLayoutModel(parameterName, expectedOrder, layoutModel);
}
Also used : ParameterGroupModel(org.mule.runtime.api.meta.model.parameter.ParameterGroupModel) LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel) EnricherTestUtils.assertLayoutModel(org.mule.runtime.module.extension.internal.loader.enricher.EnricherTestUtils.assertLayoutModel)

Example 3 with LayoutModel

use of org.mule.runtime.api.meta.model.display.LayoutModel in project mule by mulesoft.

the class LayoutModelTestCase method assertParameterPlacement.

private void assertParameterPlacement(ParameterDeclaration param, Integer order) {
    LayoutModel layout = param.getLayoutModel();
    assertThat(layout, is(notNullValue()));
    assertThat(layout.getOrder(), equalTo(ofNullable(order)));
}
Also used : LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel)

Example 4 with LayoutModel

use of org.mule.runtime.api.meta.model.display.LayoutModel in project mule by mulesoft.

the class ParameterLayoutOrderDeclarationEnricher method addMissingParameterOrders.

private int addMissingParameterOrders(List<AbstractParameterDeclaration> declarations) {
    AtomicInteger minOrder = new AtomicInteger(INITIAL_ORDER);
    Set<Integer> takenOrders = new HashSet<>();
    List<AbstractParameterDeclaration> nonOrderedParams = new ArrayList<>();
    declarations.forEach(param -> {
        LayoutModel layoutModel = param.getLayoutModel();
        if (layoutModel != null && layoutModel.getOrder().isPresent()) {
            takenOrders.add(layoutModel.getOrder().get());
            minOrder.set(min(layoutModel.getOrder().get(), minOrder.get()));
        } else {
            nonOrderedParams.add(param);
        }
    });
    AtomicInteger currentOrder = new AtomicInteger(INITIAL_ORDER);
    nonOrderedParams.forEach(param -> param.setLayoutModel(builderFrom(param.getLayoutModel()).order(getNextOrder(currentOrder, takenOrders)).build()));
    return minOrder.get();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AbstractParameterDeclaration(org.mule.runtime.api.meta.model.declaration.fluent.AbstractParameterDeclaration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) LayoutModel(org.mule.runtime.api.meta.model.display.LayoutModel)

Aggregations

LayoutModel (org.mule.runtime.api.meta.model.display.LayoutModel)4 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AbstractParameterDeclaration (org.mule.runtime.api.meta.model.declaration.fluent.AbstractParameterDeclaration)1 ParameterGroupModel (org.mule.runtime.api.meta.model.parameter.ParameterGroupModel)1 EnricherTestUtils.assertLayoutModel (org.mule.runtime.module.extension.internal.loader.enricher.EnricherTestUtils.assertLayoutModel)1