SimpleApplicationWrapper implements ApplicationWrapper { @Override public void validateConfig(Map<String, Object> props) { ApplicationConfig config = Configurable.createConfigurable(ApplicationConfig.class, props); if (config.id().equals("")) { throw new IllegalArgumentException("Application property \"id\" cannot be empty"); } else if (!config.id().matches("^[a-zA-Z0-9._\\-]+$")) { throw new IllegalArgumentException("Application property \"id\" is invalid"); } if (config.title().equals("")) { throw new IllegalArgumentException("Application property \"title\" cannot be empty"); } }  @Override void validateConfig(Map<String, Object> props); @Override String getId(); @Override Application getApplication();  }
@Test public void validateConfigTest() throws Exception { Map<String, Object> props = new HashMap<>(); props.put("id", "id"); props.put("title", "Title"); wrapper.validateConfig(props); }
@Test(expected = IllegalArgumentException.class) public void validateConfigWithNoTitle() { Map<String, Object> props = new HashMap<>(); props.put("id", "id"); props.put("title", ""); wrapper.validateConfig(props); }
@Test(expected = IllegalArgumentException.class) public void validateConfigWithInvalidId() { Map<String, Object> props = new HashMap<>(); props.put("id", "$@ ^"); props.put("title", "Title"); wrapper.validateConfig(props); }
@Test(expected = IllegalArgumentException.class) public void validateConfigWithNoId() { Map<String, Object> props = new HashMap<>(); props.put("id", ""); props.put("title", "Title"); wrapper.validateConfig(props); }