### Question:
ExpressionEditorGridRow extends BaseGridRow { @Override public double getHeight() { long currentTimeMillis = log(LOGGER, " - Pre- ExpressionEditorGridRow.getHeight()"); final double height = this.getCells() .values() .stream() .filter(cell -> cell != null && cell.getValue() != null) .map(GridCell::getValue) .filter(value -> value instanceof ExpressionCellValue) .map(value -> (ExpressionCellValue) value) .filter(value -> value.getValue().isPresent()) .map(value -> value.getValue().get()) .map(editor -> editor.getHeight() + editor.getPadding() * 2) .reduce(Double::max) .orElse(defaultHeight); log(LOGGER, " - Post- ExpressionEditorGridRow.getHeight()", currentTimeMillis); return height; } ExpressionEditorGridRow();  ExpressionEditorGridRow(final double height); @Override double getHeight(); static final double DEFAULT_HEIGHT; }### Answer:
@Test public void testEmptyRow() { final GridRow row = new ExpressionEditorGridRow(); assertThat(row.getHeight()).isEqualTo(DEFAULT_HEIGHT); }
@Test @SuppressWarnings("unchecked") public void testRowLowerThanDefault() { when(view.getHeight()).thenReturn(DEFAULT_HEIGHT - 1); final GridRow row = spy(ExpressionEditorGridRow.class); final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>() .put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))) .build(); when(row.getCells()).thenReturn(cells); assertThat(row.getHeight()).isBetween(0D, DEFAULT_HEIGHT); }
@Test @SuppressWarnings("unchecked") public void testRowHigherThanDefault() { when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1); final GridRow row = spy(ExpressionEditorGridRow.class); final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>() .put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))) .build(); when(row.getCells()).thenReturn(cells); assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT); }
@Test @SuppressWarnings("unchecked") public void testRowHigherThanDefaultWithNullCell() { when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1); final GridRow row = spy(ExpressionEditorGridRow.class); final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>() .put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))) .put(1, null) .build(); when(row.getCells()).thenReturn(cells); assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT); }
@Test @SuppressWarnings("unchecked") public void testRowHigherThanDefaultWithNullCellValue() { when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1); final GridRow row = spy(ExpressionEditorGridRow.class); final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>() .put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))) .put(1, new BaseGridCell<>(null)) .build(); when(row.getCells()).thenReturn(cells); assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT); }