PAN-46 Added validation to ProofController
This commit is contained in:
+21
-16
@@ -1,6 +1,8 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.Proof;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
|
import edu.msudenver.tsp.persistence.exception.BadRequestException;
|
||||||
|
import edu.msudenver.tsp.persistence.exception.UnprocessableEntityException;
|
||||||
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
||||||
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
import edu.msudenver.tsp.utilities.PersistenceUtilities;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -45,11 +47,11 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/id")
|
@GetMapping("/id")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<Proof> getProofById(@RequestParam("id") final Integer id) {
|
ResponseEntity<Proof> getProofById(@RequestParam("id") final Integer id) throws BadRequestException {
|
||||||
LOG.info("Received request to query for proof with id {}", id);
|
LOG.info("Received request to query for proof with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("ERROR: ID was null");
|
LOG.error("ERROR: ID was null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Specified ID is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Querying for proof with id {}", id);
|
LOG.debug("Querying for proof with id {}", id);
|
||||||
@@ -75,11 +77,12 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/branch")
|
@GetMapping("/branch")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<Proof>> getAllProofsByBranch(@RequestParam("branch") String branch) {
|
ResponseEntity<List<Proof>> getAllProofsByBranch(@RequestParam("branch") String branch)
|
||||||
|
throws BadRequestException {
|
||||||
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
|
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
|
||||||
if (branch == null) {
|
if (branch == null) {
|
||||||
LOG.error("ERROR: branch was null");
|
LOG.error("ERROR: branch was null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Specified branch is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (branch.contains("_") || branch.contains("-")) {
|
if (branch.contains("_") || branch.contains("-")) {
|
||||||
@@ -110,11 +113,12 @@ public class ProofController {
|
|||||||
|
|
||||||
@GetMapping("/theorem_name")
|
@GetMapping("/theorem_name")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<List<Proof>> getAllProofsByTheoremName(@RequestParam("theorem_name") String theoremName) {
|
ResponseEntity<List<Proof>> getAllProofsByTheoremName(@RequestParam("theorem_name") String theoremName)
|
||||||
|
throws BadRequestException {
|
||||||
LOG.info("Received request to query for proofs of the theorem {}", theoremName);
|
LOG.info("Received request to query for proofs of the theorem {}", theoremName);
|
||||||
if (theoremName == null) {
|
if (theoremName == null) {
|
||||||
LOG.error("ERROR: theorem name was null");
|
LOG.error("ERROR: theorem name was null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Specified theorem name is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (theoremName.contains("_") || theoremName.contains("-")) {
|
if (theoremName.contains("_") || theoremName.contains("-")) {
|
||||||
@@ -147,16 +151,16 @@ public class ProofController {
|
|||||||
@Validated({Proof.Insert.class, Default.class})
|
@Validated({Proof.Insert.class, Default.class})
|
||||||
public @ResponseBody ResponseEntity<Proof> insertProof(
|
public @ResponseBody ResponseEntity<Proof> insertProof(
|
||||||
@Valid @RequestBody final Proof proof,
|
@Valid @RequestBody final Proof proof,
|
||||||
final BindingResult bindingResult) {
|
final BindingResult bindingResult) throws UnprocessableEntityException, BadRequestException {
|
||||||
LOG.info("Received request to insert a new proof");
|
LOG.info("Received request to insert a new proof");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
LOG.error("Binding result is unprocessable");
|
LOG.error("Binding result is unprocessable");
|
||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
throw new UnprocessableEntityException(bindingResult.getAllErrors().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proof == null) {
|
if (proof == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Passed proof is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Saving new proof");
|
LOG.debug("Saving new proof");
|
||||||
@@ -176,22 +180,23 @@ public class ProofController {
|
|||||||
@PatchMapping("/{id}")
|
@PatchMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<Proof> updateProof(
|
public @ResponseBody ResponseEntity<Proof> updateProof(
|
||||||
@PathVariable("id") final Integer id,
|
@PathVariable("id") final Integer id,
|
||||||
@RequestBody final Proof proof, final BindingResult bindingResult) {
|
@RequestBody final Proof proof, final BindingResult bindingResult)
|
||||||
|
throws UnprocessableEntityException, BadRequestException {
|
||||||
|
|
||||||
LOG.info("Received request to update a proof");
|
LOG.info("Received request to update a proof");
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
LOG.error("Binding result is unprocessable");
|
LOG.error("Binding result is unprocessable");
|
||||||
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
|
throw new UnprocessableEntityException(bindingResult.getAllErrors().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proof == null) {
|
if (proof == null) {
|
||||||
LOG.error("Passed entity is null");
|
LOG.error("Passed entity is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Passed proof is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("Proof ID must be specified");
|
LOG.error("Proof ID must be specified");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Specified ID is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Checking for existence of proof with id {}", id);
|
LOG.debug("Checking for existence of proof with id {}", id);
|
||||||
@@ -207,7 +212,7 @@ public class ProofController {
|
|||||||
|
|
||||||
if (!existingProof.isPresent()) {
|
if (!existingProof.isPresent()) {
|
||||||
LOG.error("No proof associated with id {}", id);
|
LOG.error("No proof associated with id {}", id);
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
PersistenceUtilities.copyNonNullProperties(proof, existingProof.get());
|
PersistenceUtilities.copyNonNullProperties(proof, existingProof.get());
|
||||||
@@ -228,11 +233,11 @@ public class ProofController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
public @ResponseBody ResponseEntity<Void> deleteProofById(@PathVariable("id") final Integer id) {
|
public @ResponseBody ResponseEntity<Void> deleteProofById(@PathVariable("id") final Integer id) throws BadRequestException {
|
||||||
LOG.info("Received request to delete proof with id {}", id);
|
LOG.info("Received request to delete proof with id {}", id);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
LOG.error("Specified id is null");
|
LOG.error("Specified id is null");
|
||||||
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
|
throw new BadRequestException("Specified ID is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Deleting proof with id {}", id);
|
LOG.debug("Deleting proof with id {}", id);
|
||||||
|
|||||||
+43
-86
@@ -1,6 +1,8 @@
|
|||||||
package edu.msudenver.tsp.persistence.controller;
|
package edu.msudenver.tsp.persistence.controller;
|
||||||
|
|
||||||
import edu.msudenver.tsp.persistence.dto.Proof;
|
import edu.msudenver.tsp.persistence.dto.Proof;
|
||||||
|
import edu.msudenver.tsp.persistence.exception.BadRequestException;
|
||||||
|
import edu.msudenver.tsp.persistence.exception.UnprocessableEntityException;
|
||||||
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
import edu.msudenver.tsp.persistence.repository.ProofRepository;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@@ -45,7 +47,7 @@ public class ProofControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByBranch() {
|
public void testGetAllProofsByBranch() throws BadRequestException {
|
||||||
final Proof proofDto = createProof();
|
final Proof proofDto = createProof();
|
||||||
final List<Proof> listOfProofs = new ArrayList<>();
|
final List<Proof> listOfProofs = new ArrayList<>();
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
@@ -63,18 +65,13 @@ public class ProofControllerTest {
|
|||||||
responseEntity.getBody().forEach(proof -> assertEquals(proofDto, proof));
|
responseEntity.getBody().forEach(proof -> assertEquals(proofDto, proof));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BadRequestException.class)
|
||||||
public void testGetAllProfsByBranch_nullBranch() {
|
public void testGetAllProfsByBranch_nullBranch() throws BadRequestException {
|
||||||
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch(null);
|
proofController.getAllProofsByBranch(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByBranch_noProofsFound() {
|
public void testGetAllProofsByBranch_noProofsFound() throws BadRequestException {
|
||||||
when(proofRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
when(proofRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch("test-nonexistent-branch");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByBranch("test-nonexistent-branch");
|
||||||
@@ -85,7 +82,7 @@ public class ProofControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByTheoremName() {
|
public void testGetAllProofsByTheoremName() throws BadRequestException {
|
||||||
final Proof proofDto = createProof();
|
final Proof proofDto = createProof();
|
||||||
final List<Proof> listOfProofs = new ArrayList<>();
|
final List<Proof> listOfProofs = new ArrayList<>();
|
||||||
listOfProofs.add(proofDto);
|
listOfProofs.add(proofDto);
|
||||||
@@ -103,18 +100,13 @@ public class ProofControllerTest {
|
|||||||
responseEntity.getBody().forEach(proof -> assertEquals(proofDto, proof));
|
responseEntity.getBody().forEach(proof -> assertEquals(proofDto, proof));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BadRequestException.class)
|
||||||
public void testGetAllProofsByTheoremName_nullTheoremName() {
|
public void testGetAllProofsByTheoremName_nullTheoremName() throws BadRequestException {
|
||||||
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName(null);
|
proofController.getAllProofsByTheoremName(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllProofsByTheoremName_noProofsFound() {
|
public void testGetAllProofsByTheoremName_noProofsFound() throws BadRequestException {
|
||||||
when(proofRepository.findByTheoremName(anyString())).thenReturn(Collections.emptyList());
|
when(proofRepository.findByTheoremName(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName("test-nonexistent-proof");
|
final ResponseEntity<List<Proof>> responseEntity = proofController.getAllProofsByTheoremName("test-nonexistent-proof");
|
||||||
@@ -125,7 +117,7 @@ public class ProofControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProofById() {
|
public void testGetProofById() throws BadRequestException {
|
||||||
final Proof proof = createProof();
|
final Proof proof = createProof();
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.ofNullable(proof));
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.ofNullable(proof));
|
||||||
|
|
||||||
@@ -139,18 +131,13 @@ public class ProofControllerTest {
|
|||||||
verify(proofRepository).findById(anyInt());
|
verify(proofRepository).findById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BadRequestException.class)
|
||||||
public void testGetProofById_nullId() {
|
public void testGetProofById_nullId() throws BadRequestException {
|
||||||
final ResponseEntity responseEntity = proofController.getProofById(null);
|
proofController.getProofById(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetProofById_noProofFound() {
|
public void testGetProofById_noProofFound() throws BadRequestException {
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity responseEntity = proofController.getProofById(1);
|
final ResponseEntity responseEntity = proofController.getProofById(1);
|
||||||
@@ -162,7 +149,7 @@ public class ProofControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertProof() {
|
public void testInsertProof() throws BadRequestException, UnprocessableEntityException {
|
||||||
final Proof proof = createProof();
|
final Proof proof = createProof();
|
||||||
when(proofRepository.save(any(Proof.class))).thenReturn(proof);
|
when(proofRepository.save(any(Proof.class))).thenReturn(proof);
|
||||||
|
|
||||||
@@ -176,31 +163,21 @@ public class ProofControllerTest {
|
|||||||
verify(proofRepository).save(any(Proof.class));
|
verify(proofRepository).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BadRequestException.class)
|
||||||
public void testInsertProof_proofDtoIsNull() {
|
public void testInsertProof_proofDtoIsNull() throws BadRequestException, UnprocessableEntityException {
|
||||||
final ResponseEntity responseEntity = proofController.insertProof(null, bindingResult);
|
proofController.insertProof(null, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = UnprocessableEntityException.class)
|
||||||
public void testInsertProof_bindingResultHasErrors() {
|
public void testInsertProof_bindingResultHasErrors() throws BadRequestException, UnprocessableEntityException {
|
||||||
final Proof proof = createProof();
|
final Proof proof = createProof();
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity responseEntity = proofController.insertProof(proof, bindingResult);
|
proofController.insertProof(proof, bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof() {
|
public void testUpdateProof() throws BadRequestException, UnprocessableEntityException {
|
||||||
final Proof existingProof = createProof();
|
final Proof existingProof = createProof();
|
||||||
existingProof.setId(1);
|
existingProof.setId(1);
|
||||||
existingProof.setVersion(1);
|
existingProof.setVersion(1);
|
||||||
@@ -221,52 +198,37 @@ public class ProofControllerTest {
|
|||||||
verify(proofRepository).save(any(Proof.class));
|
verify(proofRepository).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = UnprocessableEntityException.class)
|
||||||
public void testUpdateProof_bindingResultHasErrors() {
|
public void testUpdateProof_bindingResultHasErrors() throws BadRequestException, UnprocessableEntityException {
|
||||||
when(bindingResult.hasErrors()).thenReturn(true);
|
when(bindingResult.hasErrors()).thenReturn(true);
|
||||||
|
|
||||||
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
proofController.updateProof(1, createProof(), bindingResult);
|
||||||
|
}
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
@Test(expected = BadRequestException.class)
|
||||||
assertFalse(responseEntity.hasBody());
|
public void testUpdateProof_proofDtoIsNull() throws BadRequestException, UnprocessableEntityException {
|
||||||
assertEquals(HttpStatus.UNPROCESSABLE_ENTITY, responseEntity.getStatusCode());
|
proofController.updateProof(1, null, bindingResult);
|
||||||
verifyZeroInteractions(proofRepository);
|
}
|
||||||
|
|
||||||
|
@Test(expected = BadRequestException.class)
|
||||||
|
public void testUpdateProof_idIsNull() throws BadRequestException, UnprocessableEntityException {
|
||||||
|
proofController.updateProof(null, createProof(), bindingResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUpdateProof_proofDtoIsNull() {
|
public void testUpdateProof_theoremDoesNotExist() throws BadRequestException, UnprocessableEntityException {
|
||||||
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, null, bindingResult);
|
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateProof_idIsNull() {
|
|
||||||
final ResponseEntity<Proof> responseEntity = proofController.updateProof(null, createProof(), bindingResult);
|
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testUpdateProof_theoremDoesNotExist() {
|
|
||||||
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
when(proofRepository.findById(anyInt())).thenReturn(Optional.empty());
|
||||||
|
|
||||||
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
final ResponseEntity<Proof> responseEntity = proofController.updateProof(1, createProof(), bindingResult);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
assertNotNull(responseEntity);
|
||||||
assertFalse(responseEntity.hasBody());
|
assertFalse(responseEntity.hasBody());
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
|
||||||
verify(proofRepository, times(0)).save(any(Proof.class));
|
verify(proofRepository, times(0)).save(any(Proof.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteProofById() {
|
public void testDeleteProofById() throws BadRequestException {
|
||||||
doNothing().when(proofRepository).deleteById(anyInt());
|
doNothing().when(proofRepository).deleteById(anyInt());
|
||||||
|
|
||||||
final ResponseEntity responseEntity = proofController.deleteProofById(1);
|
final ResponseEntity responseEntity = proofController.deleteProofById(1);
|
||||||
@@ -277,14 +239,9 @@ public class ProofControllerTest {
|
|||||||
verify(proofRepository).deleteById(anyInt());
|
verify(proofRepository).deleteById(anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = BadRequestException.class)
|
||||||
public void testDeleteProofById_idIsNull() {
|
public void testDeleteProofById_idIsNull() throws BadRequestException {
|
||||||
final ResponseEntity responseEntity = proofController.deleteProofById(null);
|
proofController.deleteProofById(null);
|
||||||
|
|
||||||
assertNotNull(responseEntity);
|
|
||||||
assertFalse(responseEntity.hasBody());
|
|
||||||
assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode());
|
|
||||||
verifyZeroInteractions(proofRepository);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Proof createProof() {
|
private Proof createProof() {
|
||||||
|
|||||||
Reference in New Issue
Block a user