### Question:
TrafficDensity1 { public Integer[] trafficByLane(Stream<TrafficUnit> stream, int trafficUnitsNumber, double timeSec, SpeedModel speedModel, double[] speedLimitByLane) { int lanesCount = speedLimitByLane.length; Map<Integer, Integer> trafficByLane = stream .limit(trafficUnitsNumber) .map(TrafficUnitWrapper::new) .map(tuw -> tuw.setSpeedModel(speedModel)) .map(tuw -> tuw.calcSpeed(timeSec)) .map(speed -> countByLane(lanesCount, speedLimitByLane, speed)) .collect(Collectors.groupingBy(CountByLane::getLane, Collectors.summingInt(CountByLane::getCount))); for(int i = 1; i <= lanesCount; i++){ trafficByLane.putIfAbsent(i, 0); } return trafficByLane.values().toArray(new Integer[lanesCount]); }  Integer[] trafficByLane(Stream<TrafficUnit> stream, int trafficUnitsNumber, double timeSec,
                                   SpeedModel speedModel, double[] speedLimitByLane);  }### Answer:
@Test public void testTrafficByLane() { TrafficDensity1 trafficDensity = new TrafficDensity1(); double timeSec = 10.0; int trafficUnitsNumber = 120; double[] speedLimitByLane = {30, 50, 65}; Integer[] expectedCountByLane = {30, 30, 60}; Integer[] trafficByLane = trafficDensity.trafficByLane(getTrafficUnitStream2(trafficUnitsNumber), trafficUnitsNumber, timeSec, FactorySpeedModel.getSpeedModel(), speedLimitByLane ); assertArrayEquals("Assert count of " + trafficUnitsNumber + " vehicles by " + speedLimitByLane.length + " lanes with speed limit " + Arrays.stream(speedLimitByLane).mapToObj(Double::toString).collect(Collectors.joining(", ")), expectedCountByLane, trafficByLane); }