@Test public void testSaving() { Container c = new Container("c1"); SaveService s = new SaveService(new DatabaseConnectionMock()); String exceptionString = ""; Exception ex = null; try { s.saveContainer(c); } catch (Exception e) { ex = e; exceptionString = e.getMessage(); } assert (ex == null); assert (exceptionString.equals("")); try { s.saveContainer(c); } catch (Exception e) { ex = e; exceptionString = e.getMessage(); } assert (ex != null); assert (exceptionString.equals("element already saved")); }
public void saveContainer(Container c) throws Exception { connection.saveContainer(c); }
SaveService { public void saveContainer(Container c) throws Exception { connection.saveContainer(c); } }
SaveService { public void saveContainer(Container c) throws Exception { connection.saveContainer(c); } SaveService(DatabaseConnection connection); }
SaveService { public void saveContainer(Container c) throws Exception { connection.saveContainer(c); } SaveService(DatabaseConnection connection); void saveContainer(Container c); }
SaveService { public void saveContainer(Container c) throws Exception { connection.saveContainer(c); } SaveService(DatabaseConnection connection); void saveContainer(Container c);  }