IntArrayToListResolveDependencyStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { return (T) Arrays.stream((int[]) args[0]).boxed().collect(Collectors.toList()); } catch (Exception e) { throw new ResolveDependencyStrategyException("Can't create list from int array.", e); } }  @Override T resolve(final Object... args);  }
@Test public void ShouldConvertIntArrayToList() throws ResolveDependencyStrategyException { int[] array = new int[] {1, 2, 5, 7}; List<Integer> result = strategy.resolve(array); assertEquals(result.size(), 4); assertEquals(result.get(0), new Integer(1)); assertEquals(result.get(1), new Integer(2)); assertEquals(result.get(2), new Integer(5)); assertEquals(result.get(3), new Integer(7)); }
@Test(expected = ResolveDependencyStrategyException.class) public void ShouldThrowException_When_ErrorIsOccurred() throws ResolveDependencyStrategyException { Integer[] array = new Integer[] {1, 2}; strategy.resolve(array); fail(); }