DoubleArrayToListResolveDependencyStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { return (T) Arrays.stream((double[]) args[0]).boxed().collect(Collectors.toList()); } catch (Exception e) { throw new ResolveDependencyStrategyException("Can't create list from double array.", e); } }  @Override T resolve(final Object... args);  }
@Test public void ShouldConvertDoubleArrayToList() throws ResolveDependencyStrategyException { double[] array = new double[] {12.0, 5.7, 34.33}; List<Double> result = strategy.resolve(array); assertEquals(result.size(), 3); assertEquals(result.get(0), new Double(12.0)); assertEquals(result.get(1), new Double(5.7)); assertEquals(result.get(2), new Double(34.33)); }
@Test(expected = ResolveDependencyStrategyException.class) public void ShouldThrowException_When_ErrorIsOccurred() throws ResolveDependencyStrategyException { Double[] array = new Double[] {1.0, 2.6}; strategy.resolve(array); fail(); }