### Question:
SimplePreResourceShowDetails implements IPreResourceShowDetails { @Override public void setResource(int theIndex, IBaseResource theResource) { Validate.isTrue(theIndex >= 0, "Invalid index %d - theIndex must not be < 0", theIndex); Validate.isTrue(theIndex < myResources.length, "Invalid index {} - theIndex must be < %d", theIndex, myResources.length); myResources[theIndex] = theResource; } SimplePreResourceShowDetails(IBaseResource theResource); <T extends IBaseResource> SimplePreResourceShowDetails(Collection<T> theResources); @Override int size(); @Override IBaseResource getResource(int theIndex); @Override void setResource(int theIndex, IBaseResource theResource); @Override void markResourceAtIndexAsSubset(int theIndex); @Override Iterator<IBaseResource> iterator(); List<IBaseResource> toList();  }### Answer:
@Test public void testSetResource_TooLow() { try { SimplePreResourceShowDetails details = new SimplePreResourceShowDetails(myResource1); details.setResource(-1, myResource2); fail(); } catch (IllegalArgumentException e) { assertEquals("Invalid index -1 - theIndex must not be < 0", e.getMessage()); } }
@Test public void testSetResource_TooHigh() { try { SimplePreResourceShowDetails details = new SimplePreResourceShowDetails(myResource1); details.setResource(2, myResource2); fail(); } catch (IllegalArgumentException e) { assertEquals("Invalid index {} - theIndex must be < 2", e.getMessage()); } }
@Test public void testSetResource() { SimplePreResourceShowDetails details = new SimplePreResourceShowDetails(myResource1); details.setResource(0, myResource2); assertSame(myResource2, details.iterator().next()); }