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