Skip to content
Snippets Groups Projects

Add tests for ModuleController

Files

@@ -26,13 +26,10 @@ import nl.tudelft.labracore.dto.view.ModuleViewDTO;
import nl.tudelft.labracore.repository.ModuleRepository;
import nl.tudelft.librador.dto.view.View;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.Errors;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@Transactional
@@ -40,8 +37,6 @@ import org.springframework.web.bind.annotation.*;
@RestController
public class ModuleController {
private static final Logger logger = LoggerFactory.getLogger(ModuleController.class);
@Autowired
private ApplicationContext context;
@@ -55,7 +50,6 @@ public class ModuleController {
* @param errors The result of validating the create DTO.
* @return The id under which the module was added.
*/
@Validated
@PostMapping
@PreAuthorize("hasAuthority('MODULE_CREATE')")
public Long addModule(@Valid @RequestBody ModuleCreateDTO dto, Errors errors) {
@@ -84,7 +78,7 @@ public class ModuleController {
* @param id the id of the module
* @return the details of this module
*/
@GetMapping("/{id}")
@GetMapping("{id}")
@PreAuthorize("hasAuthority('MODULE_READ')")
public ModuleViewDTO getModuleDetails(@PathVariable Long id) {
return View.convert(mr.findByIdOrThrow(id), ModuleViewDTO.class);
Loading