ShortArrayToListResolveDependencyStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { short[] shorts = (short[]) args[0]; List<Short> result = new ArrayList<>(shorts.length); for (short aShort : shorts) { result.add(aShort); } return (T) result; } catch (Exception e) { throw new ResolveDependencyStrategyException("Can't create list from short array.", e); } }  @Override T resolve(final Object... args);  }
@Test public void ShouldConvertShortArrayToList() throws ResolveDependencyStrategyException { short[] array = new short[] {1, 2, 3}; List<Short> result = strategy.resolve(array); assertEquals(result.size(), 3); assertEquals(result.get(0), new Short("1")); assertEquals(result.get(1), new Short("2")); assertEquals(result.get(2), new Short("3")); }
@Test(expected = ResolveDependencyStrategyException.class) public void ShouldThrowException_When_ErrorIsOccurred() throws ResolveDependencyStrategyException { Short[] array = new Short[] {1, 2}; strategy.resolve(array); fail(); }