ByteArrayToListResolveDependencyStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { byte[] bytes = (byte[]) args[0]; List<Byte> result = new ArrayList<>(bytes.length); for (byte aByte : bytes) { result.add(aByte); } return (T) result; } catch (Exception e) { throw new ResolveDependencyStrategyException("Can't create list from byte array.", e); } }  @Override T resolve(final Object... args);  }
@Test public void ShouldConvertByteArrayToList() throws ResolveDependencyStrategyException { byte[] array = new byte[] {(byte)0xba, (byte)0x8a}; List<Byte> result = strategy.resolve(array); assertEquals(result.size(), 2); assertEquals(result.get(0), new Byte((byte) 0xba)); assertEquals(result.get(1), new Byte((byte) 0x8a)); }
@Test(expected = ResolveDependencyStrategyException.class) public void ShouldThrowException_When_ErrorIsOccurred() throws ResolveDependencyStrategyException { String invalid = "invalid"; strategy.resolve(invalid); fail(); }