minor formatting work

This commit is contained in:
eugenp 2016-01-24 23:12:31 +02:00
parent e8bfbd7881
commit bec77d6a89
9 changed files with 8 additions and 39 deletions

View File

@ -16,7 +16,7 @@ import com.google.common.collect.Lists;
@Service @Service
@Transactional @Transactional
public class FooService extends AbstractService<Foo>implements IFooService { public class FooService extends AbstractService<Foo> implements IFooService {
@Autowired @Autowired
private IFooDao dao; private IFooDao dao;

View File

@ -27,7 +27,6 @@ public class ActuatorMetricService implements IActuatorMetricService {
statusList = new ArrayList<String>(); statusList = new ArrayList<String>();
} }
@Override @Override
public Object[][] getGraphData() { public Object[][] getGraphData() {
final Date current = new Date(); final Date current = new Date();

View File

@ -4,7 +4,6 @@ import java.io.Serializable;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
public class Foo implements Serializable { public class Foo implements Serializable {
private long id; private long id;

View File

@ -19,35 +19,13 @@ import static com.google.common.collect.Lists.newArrayList;
public class SwaggerConfig { public class SwaggerConfig {
@Bean @Bean
public Docket api(){ public Docket api() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("org.baeldung.web.controller")).paths(PathSelectors.ant("/foos/*")).build().apiInfo(apiInfo()).useDefaultResponseMessages(false)
.select() .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build(), new ResponseMessageBuilder().code(403).message("Forbidden!!!!!").build()));
.apis(RequestHandlerSelectors.basePackage("org.baeldung.web.controller"))
.paths(PathSelectors.ant("/foos/*"))
.build()
.apiInfo(apiInfo())
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET,
newArrayList(new ResponseMessageBuilder()
.code(500)
.message("500 message")
.responseModel(new ModelRef("Error"))
.build(),
new ResponseMessageBuilder()
.code(403)
.message("Forbidden!!!!!")
.build()));
} }
private ApiInfo apiInfo() { private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo( ApiInfo apiInfo = new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", "myeaddress@company.com", "License of API", "API license URL");
"My REST API",
"Some custom description of API.",
"API TOS",
"Terms of service",
"myeaddress@company.com",
"License of API",
"API license URL");
return apiInfo; return apiInfo;
} }
} }

View File

@ -21,11 +21,9 @@ public class WebConfig extends WebMvcConfigurerAdapter {
@Override @Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) { public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html") registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**") registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
.addResourceLocations("classpath:/META-INF/resources/webjars/");
} }
@Bean @Bean

View File

@ -48,6 +48,7 @@ public class ApiError {
public void setMessage(final String message) { public void setMessage(final String message) {
this.message = message; this.message = message;
} }
public List<String> getErrors() { public List<String> getErrors() {
return errors; return errors;
} }

View File

@ -100,7 +100,6 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
} }
@ExceptionHandler({ ConstraintViolationException.class }) @ExceptionHandler({ ConstraintViolationException.class })
public ResponseEntity<Object> handleConstraintViolation(final ConstraintViolationException ex, final WebRequest request) { public ResponseEntity<Object> handleConstraintViolation(final ConstraintViolationException ex, final WebRequest request) {
logger.info(ex.getClass().getName()); logger.info(ex.getClass().getName());
@ -156,7 +155,6 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus()); return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
} }
// 500 // 500
@ExceptionHandler({ Exception.class }) @ExceptionHandler({ Exception.class })
@ -169,4 +167,3 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
} }
} }

View File

@ -34,8 +34,6 @@ public class FooLiveTest {
assertTrue(error.getErrors().get(0).contains("should be of type")); assertTrue(error.getErrors().get(0).contains("should be of type"));
} }
@Test @Test
public void whenNoHandlerForHttpRequest_thenNotFound() { public void whenNoHandlerForHttpRequest_thenNotFound() {
final Response response = givenAuth().delete(URL_PREFIX + "/api/xx"); final Response response = givenAuth().delete(URL_PREFIX + "/api/xx");

View File

@ -7,5 +7,4 @@ import org.springframework.context.annotation.Configuration;
@ComponentScan({ "org.baeldung.web" }) @ComponentScan({ "org.baeldung.web" })
public class TestConfig { public class TestConfig {
} }