Skip to content

Commit

Permalink
add tests for OcppTagsRestController (#910)
Browse files Browse the repository at this point in the history
  • Loading branch information
goekay committed Sep 30, 2022
1 parent 5afa658 commit d0ded00
Show file tree
Hide file tree
Showing 4 changed files with 435 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.server.ResponseStatusException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJackson2JsonView;
Expand Down Expand Up @@ -66,6 +67,13 @@ public ModelAndView handleResponseStatusException(HttpServletRequest req, Respon
return createResponse(url, exception.getStatus(), exception.getReason());
}

@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ModelAndView handleMethodArgumentTypeMismatchException(HttpServletRequest req, MethodArgumentTypeMismatchException exception) {
StringBuffer url = req.getRequestURL();
log.error("Request: {} raised following exception.", url, exception);
return createResponse(url, HttpStatus.BAD_REQUEST, exception.getMessage());
}

@ExceptionHandler(Exception.class)
public ModelAndView handleException(HttpServletRequest req, Exception exception) {
StringBuffer url = req.getRequestURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
*/
@Slf4j
@RestController
@RequestMapping(value = "/api/v1/ocppTags", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/api/v1/ocppTags", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@RequiredArgsConstructor
public class OcppTagsRestController {

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/rwth/idsg/steve/web/dto/OcppTagForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package de.rwth.idsg.steve.web.dto;

import de.rwth.idsg.steve.web.validation.IdTag;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand All @@ -35,6 +36,7 @@
@Getter
@Setter
@ToString
@EqualsAndHashCode
public class OcppTagForm {

// Internal database id
Expand Down
Loading

0 comments on commit d0ded00

Please sign in to comment.