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