ObjectArrayToListResolveDependencyStrategy implements IResolveDependencyStrategy { @Override public <T> T resolve(final Object... args) throws ResolveDependencyStrategyException { try { return (T) Arrays.asList(args); } catch (Exception e) { throw new ResolveDependencyStrategyException("Can't create list from array.", e); } }  @Override T resolve(final Object... args);  }
@Test public void ShouldConvertObjectArrayToList() throws ResolveDependencyStrategyException { Object object = new Object(); Object[] array = new Object[] {1L, "string", object}; List<Short> result = strategy.resolve(array); assertEquals(result.size(), 3); assertEquals(result.get(0), new Long(1L)); assertEquals(result.get(1), "string"); assertEquals(result.get(2), object); }
@Test public void ShouldConvertConcreteTypeArrayToList() throws ResolveDependencyStrategyException { Integer[] array = new Integer[] {new Integer(1), new Integer(143)}; List<Short> result = strategy.resolve(array); assertEquals(result.size(), 2); assertEquals(result.get(0), new Integer(1)); assertEquals(result.get(1), new Integer(143)); }
@Test(expected = ResolveDependencyStrategyException.class) public void ShouldThrowException_When_ErrorIsOccurred() throws ResolveDependencyStrategyException { strategy.resolve(null); fail(); }