ApplicationRegistry { public Application register(Application app) { Validate.notNull(app, "Application must not be null"); Validate.notNull(app.getId(), "ID must not be null"); Validate.notNull(app.getUrl(), "URL must not be null"); Validate.isTrue(checkUrl(app.getUrl()), "URL is not valid"); return registry.put(app.getId(), app); }  Application register(Application app); boolean isRegistered(String id); List<Application> getApplications(); Application getApplication(String id);  }
@Test(expected = NullPointerException.class) public void registerFailed1() throws Exception { registry.register(new Application()); }
@Test(expected = NullPointerException.class) public void registerFailed2() throws Exception { Application app = new Application(); app.setId("abc"); registry.register(app); }
@Test(expected = IllegalArgumentException.class) public void registerFailed3() throws Exception { Application app = new Application(); app.setId("abc"); app.setUrl("not-an-url"); registry.register(app); }
@Test public void register() throws Exception { Application app = new Application(); app.setId("abc"); app.setUrl("http: registry.register(app); }