ApiValidator implements Validator { @Override public void validate(Api definition) { if (definition.getName() == null || definition.getName().isEmpty()) { throw new ValidationException("An API must have a name"); } if (definition.getPaths() == null || definition.getPaths().isEmpty()) { throw new ValidationException("An API must have, at least, one path defined (default is /*)"); } }  @Override void validate(Api definition);  }
@Test(expected = ValidationException.class) public void validate_emptyDefinition() { Api definition = new Api(); new ApiValidator().validate(definition); }
@Test(expected = ValidationException.class) public void validate_noPathDefinition() { Api definition = new Api(); definition.setName("api-test"); new ApiValidator().validate(definition); }
@Test(expected = ValidationException.class) public void validate_emptyPathDefinition() { Api definition = new Api(); definition.setName("api-test"); definition.setPaths(new HashMap<>()); new ApiValidator().validate(definition); }