SmilResponseImpl implements SmilResponse { @Override public SmilObject[] getEntities() throws SmilException { if (entities.length == 0) { throw new SmilException("There are no entities."); } return entities; } private  SmilResponseImpl();  SmilResponseImpl(Smil smil);  SmilResponseImpl(Smil smil, SmilObject entity);  SmilResponseImpl(Smil smil, SmilObject[] entities); @XmlElement(type = SmilImpl.class, required = true) @Override Smil getSmil(); @Override int getEntitiesCount(); @Override SmilObject getEntity(); @Override SmilObject[] getEntities(); @Override String toXml(); static SmilResponse fromXml(String smilResponseXml);  }
@Test public void testGetEntities() throws Exception { Smil smil = new SmilImpl(); SmilResponse response = new SmilResponseImpl(smil); try { response.getEntities(); fail("getEntities should fail, if entity count is zero"); } catch (SmilException ex) { } response = new SmilResponseImpl(smil, smil.getBody()); try { SmilObject[] entities = response.getEntities(); assertSame(1, entities.length); assertSame(smil.getBody(), entities[0]); } catch (SmilException ex) { fail("getEntities should not throw an Exception if some entities are set"); } response = new SmilResponseImpl(smil, new SmilObject[]{smil.getHead(), smil.getBody()}); try { SmilObject[] entities = response.getEntities(); assertSame(2, entities.length); assertSame(smil.getHead(), entities[0]); assertSame(smil.getBody(), entities[1]); } catch (SmilException ex) { fail("getEntities should not throw an Exception if some entities are set"); } }