minor formatting work
This commit is contained in:
parent
e8bfbd7881
commit
bec77d6a89
|
@ -16,7 +16,7 @@ import com.google.common.collect.Lists;
|
|||
|
||||
@Service
|
||||
@Transactional
|
||||
public class FooService extends AbstractService<Foo>implements IFooService {
|
||||
public class FooService extends AbstractService<Foo> implements IFooService {
|
||||
|
||||
@Autowired
|
||||
private IFooDao dao;
|
||||
|
|
|
@ -27,7 +27,6 @@ public class ActuatorMetricService implements IActuatorMetricService {
|
|||
statusList = new ArrayList<String>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object[][] getGraphData() {
|
||||
final Date current = new Date();
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.Serializable;
|
|||
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
|
||||
public class Foo implements Serializable {
|
||||
|
||||
private long id;
|
||||
|
|
|
@ -19,35 +19,13 @@ import static com.google.common.collect.Lists.newArrayList;
|
|||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket api(){
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.select()
|
||||
.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()));
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).select().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() {
|
||||
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");
|
||||
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");
|
||||
return apiInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,9 @@ public class WebConfig extends WebMvcConfigurerAdapter {
|
|||
|
||||
@Override
|
||||
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -48,6 +48,7 @@ public class ApiError {
|
|||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
|
|||
return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
|
||||
}
|
||||
|
||||
|
||||
@ExceptionHandler({ ConstraintViolationException.class })
|
||||
public ResponseEntity<Object> handleConstraintViolation(final ConstraintViolationException ex, final WebRequest request) {
|
||||
logger.info(ex.getClass().getName());
|
||||
|
@ -156,7 +155,6 @@ public class CustomRestExceptionHandler extends ResponseEntityExceptionHandler {
|
|||
return new ResponseEntity<Object>(apiError, new HttpHeaders(), apiError.getStatus());
|
||||
}
|
||||
|
||||
|
||||
// 500
|
||||
|
||||
@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"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void whenNoHandlerForHttpRequest_thenNotFound() {
|
||||
final Response response = givenAuth().delete(URL_PREFIX + "/api/xx");
|
||||
|
|
|
@ -7,5 +7,4 @@ import org.springframework.context.annotation.Configuration;
|
|||
@ComponentScan({ "org.baeldung.web" })
|
||||
public class TestConfig {
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue