PAN-50 Addressed Brittany's comment about nonexistent fields
This commit is contained in:
+12
@@ -62,6 +62,12 @@ public class TheoremController {
|
|||||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||||
|
|
||||||
|
if (listOfTheorems.isEmpty()) {
|
||||||
|
LOG.warn("No theorems were found for branch {}", branch);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("Returning list of theorems with branch {}", branch);
|
||||||
return new ResponseEntity<>(listOfTheorems, HttpStatus.OK);
|
return new ResponseEntity<>(listOfTheorems, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +92,12 @@ public class TheoremController {
|
|||||||
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
LOG.debug("Received response from server: query took " + stopWatch.getTotalTimeMillis() + "ms to complete");
|
||||||
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
LOG.info("Returning list of all theorems with size " + listOfTheorems.size());
|
||||||
|
|
||||||
|
if (listOfTheorems.isEmpty()) {
|
||||||
|
LOG.warn("No theorems were found for proven status {}", provenStatus);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("Returning list of theorems with proven status {}", provenStatus);
|
||||||
return new ResponseEntity<>(listOfTheorems, HttpStatus.OK);
|
return new ResponseEntity<>(listOfTheorems, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
@@ -14,6 +14,7 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@@ -114,6 +115,17 @@ public class TheoremControllerTest {
|
|||||||
verifyZeroInteractions(theoremRepository);
|
verifyZeroInteractions(theoremRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllTheoremsByBranch_noTheoremsFound() {
|
||||||
|
when(theoremRepository.findByBranch(anyString())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
|
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByBranch("test nonexistent branch");
|
||||||
|
|
||||||
|
assertNotNull(responseEntity);
|
||||||
|
assertFalse(responseEntity.hasBody());
|
||||||
|
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllTheoremsByProvenStatus() {
|
public void testGetAllTheoremsByProvenStatus() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final TheoremDto theoremDto = createTheorem();
|
||||||
@@ -143,6 +155,17 @@ public class TheoremControllerTest {
|
|||||||
verifyZeroInteractions(theoremRepository);
|
verifyZeroInteractions(theoremRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetAllTheoremsByProvenStatus_noTheoremsFound() {
|
||||||
|
when(theoremRepository.findByProvenStatus(anyBoolean())).thenReturn(Collections.emptyList());
|
||||||
|
|
||||||
|
final ResponseEntity<List<TheoremDto>> responseEntity = theoremController.getAllTheoremsByProvenStatus(false);
|
||||||
|
|
||||||
|
assertNotNull(responseEntity);
|
||||||
|
assertFalse(responseEntity.hasBody());
|
||||||
|
assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInsertTheorem() {
|
public void testInsertTheorem() {
|
||||||
final TheoremDto theoremDto = createTheorem();
|
final TheoremDto theoremDto = createTheorem();
|
||||||
|
|||||||
Reference in New Issue
Block a user