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));
}
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);
}
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)));
}
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();
}
Aggregations