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
@Transactional
public class FooService extends AbstractService<Foo>implements IFooService {
public class FooService extends AbstractService<Foo> implements IFooService {
@Autowired
private IFooDao dao;

View File

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

View File

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

View File

@ -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;
}
}

View File

@ -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

View File

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

View File

@ -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 {
}
}

View File

@ -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");

View File

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