List of usage examples for java.util.stream IntStream forEach
void forEach(IntConsumer action);
From source file:org.kie.workbench.common.forms.migration.tool.pipelines.basic.AbstractFormDefinitionGeneratorTest.java
protected void verifyLineForm(FormMigrationSummary summary) { Form originalForm = summary.getOriginalForm().get(); Assertions.assertThat(originalForm.getFormFields()).isNotEmpty().hasSize(4); FormDefinition newForm = summary.getNewForm().get(); Assertions.assertThat(newForm.getFields()).isNotEmpty().hasSize(4); Assertions.assertThat(newForm.getModel()).isNotNull().hasFieldOrPropertyWithValue("className", LINE_MODEL) .isInstanceOf(DataObjectFormModel.class); IntStream indexStream = IntStream.range(0, newForm.getFields().size()); LayoutTemplate formLayout = newForm.getLayoutTemplate(); assertNotNull(formLayout);/*w ww .jav a 2 s. c o m*/ Assertions.assertThat(formLayout.getRows()).isNotEmpty().hasSize(1); LayoutRow fieldRow = formLayout.getRows().get(0); indexStream.forEach(index -> { FieldDefinition fieldDefinition = newForm.getFields().get(index); switch (index) { case 0: checkFieldDefinition(fieldDefinition, LINE_PRODUCT, "product", "product", TextBoxFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName())); break; case 1: checkFieldDefinition(fieldDefinition, LINE_PRICE, "price", "price", DecimalBoxFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName())); break; case 2: checkFieldDefinition(fieldDefinition, LINE_QUANTITY, "quantity", "quantity", IntegerBoxFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName())); break; case 3: checkFieldDefinition(fieldDefinition, LINE_TOTAL, "total", "total", DecimalBoxFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName())); break; } assertNotNull(fieldRow); Assertions.assertThat(fieldRow.getLayoutColumns()).isNotEmpty().hasSize(4); LayoutColumn fieldColumn = fieldRow.getLayoutColumns().get(index); assertNotNull(fieldColumn); assertEquals("3", fieldColumn.getSpan()); Assertions.assertThat(fieldColumn.getLayoutComponents()).isNotEmpty().hasSize(1); checkLayoutFormField(fieldColumn.getLayoutComponents().get(0), fieldDefinition, newForm); }); }