use of java.util.stream.IntStream in project jdk8u_jdk by JetBrains.
the class ConcatTest method assertIntConcat.
private void assertIntConcat(Stream<Integer> s1, Stream<Integer> s2, boolean parallel, boolean ordered) {
IntStream result = IntStream.concat(s1.mapToInt(Integer::intValue), s2.mapToInt(Integer::intValue));
assertEquals(result.isParallel(), parallel);
assertConcatContent(result.spliterator(), ordered, expected.stream().mapToInt(Integer::intValue).spliterator());
}
use of java.util.stream.IntStream in project jdk8u_jdk by JetBrains.
the class CountTest method testOps.
@Test(dataProvider = "IntStreamTestData", dataProviderClass = IntStreamTestDataProvider.class)
public void testOps(String name, TestData.OfInt data) {
AtomicLong expectedCount = new AtomicLong();
data.stream().forEach(e -> expectedCount.incrementAndGet());
withData(data).terminal(IntStream::count).expectedResult(expectedCount.get()).exercise();
}
use of java.util.stream.IntStream in project incubator-systemml by apache.
the class DenseBlockLDRB method reset.
@SuppressWarnings("resource")
private void reset(int rlen, int clen, int blen, double v) {
long llen = (long) rlen * clen;
int numPart = (int) Math.ceil((double) rlen / blen);
if (this.blen == blen && llen < capacity()) {
for (int i = 0; i < numPart; i++) {
int lrlen = (int) (Math.min((i + 1) * blen, rlen) - i * blen);
Arrays.fill(data[i], 0, lrlen * clen, v);
}
} else {
data = new double[numPart][];
IntStream range = PARALLEL_ALLOC ? IntStream.range(0, numPart).parallel() : IntStream.range(0, numPart);
range.forEach(i -> data[i] = allocArray(i, rlen, clen, blen, v));
}
this.rlen = rlen;
this.clen = clen;
this.blen = blen;
}
use of java.util.stream.IntStream in project kie-wb-common by kiegroup.
the class AllFieldTypesFormGenerationTest method testMigration.
@Test
public void testMigration() {
generator.execute(context);
Assertions.assertThat(context.getSummaries()).isNotEmpty().hasSize(1);
Assertions.assertThat(context.getExtraSummaries()).isEmpty();
// 1 legacyforms + 1 migrated forms
verify(migrationServicesCDIWrapper, times(2)).write(any(Path.class), anyString(), anyString());
FormMigrationSummary summary = context.getSummaries().iterator().next();
Form originalForm = summary.getOriginalForm().get();
FormDefinition newForm = summary.getNewForm().get();
assertNotNull(newForm);
Assertions.assertThat(newForm.getFields()).isNotEmpty().hasSize(fieldMappings.size());
LayoutTemplate newLayout = newForm.getLayoutTemplate();
assertNotNull(newLayout);
Assertions.assertThat(newLayout.getRows()).isNotEmpty().hasSize(// fields + 2 decorators in original form
fieldMappings.size() + 2);
List<LayoutRow> rows = newLayout.getRows();
checkDecoratorRow(rows.get(0));
checkDecoratorRow(rows.get(1));
IntStream indexStream = IntStream.range(0, fieldMappings.size());
indexStream.forEach(index -> {
FieldDefinition newField = newForm.getFields().get(index);
assertNotNull(newField);
Field originalField = originalForm.getField(newField.getName());
assertNotNull(originalField);
checkFieldDefinition(newField, newField.getName(), newField.getLabel(), newField.getBinding(), fieldMappings.get(newField.getName()), newForm, originalField);
LayoutRow row = rows.get(index + 2);
LayoutComponent component = checkRow(row);
checkLayoutFormField(component, newField, newForm);
});
}
use of java.util.stream.IntStream in project kie-wb-common by kiegroup.
the class AbstractFormDefinitionGeneratorTest method verifyInvoiceForm.
protected void verifyInvoiceForm(FormMigrationSummary summary) {
Form originalForm = summary.getOriginalForm().get();
Assertions.assertThat(originalForm.getFormFields()).isNotEmpty().hasSize(3);
FormDefinition newForm = summary.getNewForm().get();
Assertions.assertThat(newForm.getFields()).isNotEmpty().hasSize(3);
Assertions.assertThat(newForm.getModel()).isNotNull().hasFieldOrPropertyWithValue("className", INVOICE_MODEL).isInstanceOf(DataObjectFormModel.class);
IntStream indexStream = IntStream.range(0, newForm.getFields().size());
LayoutTemplate formLayout = newForm.getLayoutTemplate();
assertNotNull(formLayout);
Assertions.assertThat(formLayout.getRows()).isNotEmpty().hasSize(newForm.getFields().size());
indexStream.forEach(index -> {
FieldDefinition fieldDefinition = newForm.getFields().get(index);
switch(index) {
case 0:
checkFieldDefinition(fieldDefinition, INVOICE_USER, "user (invoice)", "user", SubFormFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName()));
break;
case 1:
checkFieldDefinition(fieldDefinition, INVOICE_LINES, "lines (invoice)", "lines", MultipleSubFormFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName()));
break;
case 3:
checkFieldDefinition(fieldDefinition, INVOICE_LINES, "lines (invoice)", "lines", MultipleSubFormFieldDefinition.class, newForm, originalForm.getField(fieldDefinition.getName()));
break;
}
LayoutRow fieldRow = formLayout.getRows().get(index);
assertNotNull(fieldRow);
Assertions.assertThat(fieldRow.getLayoutColumns()).isNotEmpty().hasSize(1);
LayoutColumn fieldColumn = fieldRow.getLayoutColumns().get(0);
assertNotNull(fieldColumn);
assertEquals("12", fieldColumn.getSpan());
Assertions.assertThat(fieldColumn.getLayoutComponents()).isNotEmpty().hasSize(1);
checkLayoutFormField(fieldColumn.getLayoutComponents().get(0), fieldDefinition, newForm);
});
}
Aggregations