minor formatting work
This commit is contained in:
parent
e8bfbd7881
commit
bec77d6a89
|
@ -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();
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -20,34 +20,12 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
|
|
@ -7,5 +7,4 @@ import org.springframework.context.annotation.Configuration;
|
||||||
@ComponentScan({ "org.baeldung.web" })
|
@ComponentScan({ "org.baeldung.web" })
|
||||||
public class TestConfig {
|
public class TestConfig {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue