Browse Source

Part 3.1.8 - Test Poll Creating Capabilities

Nick Satinover 6 years ago
parent
commit
09450b2bfd

+ 18
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controllers/PollController.java View File

@@ -43,5 +43,23 @@ public class PollController {
43 43
         return new ResponseEntity<>(httpHeaders, HttpStatus.CREATED);
44 44
     }
45 45
 
46
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.GET)
47
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId){
48
+        Poll p = pollRepository.findOne(pollId);
49
+        return new ResponseEntity<>(p, HttpStatus.OK);
50
+    }
51
+
52
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.PUT)
53
+    public ResponseEntity<?> updatePoll(@RequestBody Poll poll, @PathVariable Long pollId){
54
+        Poll p = pollRepository.save(poll);
55
+        return new ResponseEntity<>(HttpStatus.OK);
56
+    }
57
+
58
+    @RequestMapping(value = "/polls{pollId}", method = RequestMethod.DELETE)
59
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId){
60
+        pollRepository.delete(pollId);
61
+        return new ResponseEntity<>(HttpStatus.OK);
62
+    }
63
+
46 64
 
47 65
 }