Garrett Arant vor 8 Jahren
Ursprung
Commit
b02e40de7e

+ 22
- 0
src/main/java/dtos/OptionCount.java Datei anzeigen

@@ -0,0 +1,22 @@
1
+package dtos;
2
+
3
+public class OptionCount {
4
+    private Long optionId;
5
+    private int count;
6
+
7
+    public Long getOptionId() {
8
+        return optionId;
9
+    }
10
+
11
+    public void setOptionId(Long optionId) {
12
+        this.optionId = optionId;
13
+    }
14
+
15
+    public int getCount() {
16
+        return count;
17
+    }
18
+
19
+    public void setCount(int count) {
20
+        this.count = count;
21
+    }
22
+}

+ 24
- 0
src/main/java/dtos/VoteResult.java Datei anzeigen

@@ -0,0 +1,24 @@
1
+package dtos;
2
+
3
+import java.util.Collection;
4
+
5
+public class VoteResult {
6
+    private int totalVotes;
7
+    private Collection<OptionCount> results;
8
+
9
+    public int getTotalVotes() {
10
+        return totalVotes;
11
+    }
12
+
13
+    public void setTotalVotes(int totalVotes) {
14
+        this.totalVotes = totalVotes;
15
+    }
16
+
17
+    public Collection<OptionCount> getResults() {
18
+        return results;
19
+    }
20
+
21
+    public void setResults(Collection<OptionCount> results) {
22
+        this.results = results;
23
+    }
24
+}

+ 68
- 0
src/main/java/dtos/error/ErrorDetail.java Datei anzeigen

@@ -0,0 +1,68 @@
1
+package dtos.error;
2
+
3
+
4
+import java.util.HashMap;
5
+import java.util.List;
6
+import java.util.Map;
7
+
8
+public class ErrorDetail {
9
+
10
+    private String title;
11
+    private int status;
12
+    private String detail;
13
+    private long timeStamp;
14
+    private String developerMessage;
15
+
16
+    private Map<String, List<ValidationError>> errors = new HashMap<>();
17
+
18
+
19
+    public String getTitle() {
20
+        return title;
21
+    }
22
+
23
+    public void setTitle(String title) {
24
+        this.title = title;
25
+    }
26
+
27
+    public int getStatus() {
28
+        return status;
29
+    }
30
+
31
+    public void setStatus(int status) {
32
+        this.status = status;
33
+    }
34
+
35
+    public String getDetail() {
36
+        return detail;
37
+    }
38
+
39
+    public void setDetail(String detail) {
40
+        this.detail = detail;
41
+    }
42
+
43
+    public long getTimeStamp() {
44
+        return timeStamp;
45
+    }
46
+
47
+    public void setTimeStamp(long timeStamp) {
48
+        this.timeStamp = timeStamp;
49
+    }
50
+
51
+    public String getDeveloperMessage() {
52
+        return developerMessage;
53
+    }
54
+
55
+    public void setDeveloperMessage(String developerMessage) {
56
+        this.developerMessage = developerMessage;
57
+    }
58
+
59
+    public Map<String, List<ValidationError>> getErrors() {
60
+        return errors;
61
+    }
62
+
63
+    public void setErrors(Map<String, List<ValidationError>> errors) {
64
+        this.errors = errors;
65
+    }
66
+
67
+
68
+}

+ 73
- 0
src/main/java/dtos/error/RestExceptionHandler.java Datei anzeigen

@@ -0,0 +1,73 @@
1
+package dtos.error;
2
+
3
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
4
+import org.springframework.context.MessageSource;
5
+import org.springframework.http.HttpStatus;
6
+import org.springframework.http.ResponseEntity;
7
+import org.springframework.validation.FieldError;
8
+import org.springframework.web.bind.MethodArgumentNotValidException;
9
+import org.springframework.web.bind.annotation.ControllerAdvice;
10
+import org.springframework.web.bind.annotation.ExceptionHandler;
11
+import org.springframework.web.bind.annotation.ResponseBody;
12
+import org.springframework.web.bind.annotation.ResponseStatus;
13
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
14
+
15
+import javax.inject.Inject;
16
+import javax.servlet.http.HttpServletRequest;
17
+import java.util.ArrayList;
18
+import java.util.Date;
19
+import java.util.List;
20
+
21
+@ControllerAdvice
22
+public class RestExceptionHandler extends ResponseEntityExceptionHandler {
23
+
24
+    @Inject
25
+    private MessageSource messageSource;
26
+
27
+    @ExceptionHandler(ResourceNotFoundException.class)
28
+    @ResponseStatus
29
+    public ResponseEntity<?> handlerResourceNotFoundException(
30
+            ResourceNotFoundException rnfe, HttpServletRequest request) {
31
+        ErrorDetail errorDetail = new ErrorDetail();
32
+        errorDetail.setTimeStamp(new Date().getTime());
33
+        errorDetail.setStatus(HttpStatus.NOT_FOUND.value());
34
+        errorDetail.setTitle("Resource Not Found");
35
+        errorDetail.setDetail(rnfe.getMessage());
36
+        errorDetail.setDeveloperMessage(rnfe.getClass().getName());
37
+
38
+        return new ResponseEntity<>(errorDetail, null, HttpStatus.NOT_FOUND);
39
+    }
40
+
41
+    @ExceptionHandler(MethodArgumentNotValidException.class)
42
+    @ResponseStatus(HttpStatus.BAD_REQUEST)
43
+    public @ResponseBody
44
+    ErrorDetail handleValidationError(MethodArgumentNotValidException manve, HttpServletRequest request) {
45
+        ErrorDetail errorDetail = new ErrorDetail();
46
+        errorDetail.setTitle("Validation Failed");
47
+        errorDetail.setStatus(HttpStatus.BAD_REQUEST.value());
48
+        errorDetail.setDetail("Input validation failed");
49
+        errorDetail.setTimeStamp(new Date().getTime());
50
+        errorDetail.setDeveloperMessage(manve.getClass().getName());
51
+
52
+        String requestPath = (String) request.getAttribute("javax.servlet.error.request_uri");
53
+
54
+        if (requestPath == null) {
55
+            requestPath = request.getRequestURI();
56
+        }
57
+
58
+        List<FieldError> fieldErrors = manve.getBindingResult().getFieldErrors();
59
+        for (FieldError fe : fieldErrors) {
60
+            List<ValidationError> validationErrorList = errorDetail.getErrors().get(fe.getField());
61
+            if (validationErrorList == null) {
62
+                validationErrorList = new ArrayList<ValidationError>();
63
+                errorDetail.getErrors().put(fe.getField(), validationErrorList);
64
+            }
65
+            ValidationError validationError = new ValidationError();
66
+            validationError.setCode(fe.getCode());
67
+            validationError.setMessage(messageSource.getMessage(fe, null));
68
+            validationErrorList.add(validationError);
69
+
70
+        }
71
+        return errorDetail;
72
+    }
73
+}

+ 23
- 0
src/main/java/dtos/error/ValidationError.java Datei anzeigen

@@ -0,0 +1,23 @@
1
+package dtos.error;
2
+
3
+public class ValidationError {
4
+
5
+    private String code;
6
+    private String message;
7
+
8
+    public String getCode() {
9
+        return code;
10
+    }
11
+
12
+    public void setCode(String code) {
13
+        this.code = code;
14
+    }
15
+
16
+    public String getMessage() {
17
+        return message;
18
+    }
19
+
20
+    public void setMessage(String message) {
21
+        this.message = message;
22
+    }
23
+}

+ 28
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/ComputeResultController.java Datei anzeigen

@@ -0,0 +1,28 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import dtos.VoteResult;
4
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
5
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
6
+import org.springframework.http.HttpStatus;
7
+import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestMethod;
10
+import org.springframework.web.bind.annotation.RequestParam;
11
+import org.springframework.web.bind.annotation.RestController;
12
+
13
+import javax.inject.Inject;
14
+
15
+@RestController
16
+public class ComputeResultController {
17
+    @Inject
18
+    private VoteRepository voteRepository;
19
+
20
+    @RequestMapping(value = "/computeresult", method = RequestMethod.GET)
21
+    public ResponseEntity<?> computeResult(@RequestParam Long pollId) {
22
+        VoteResult voteResult = new VoteResult();
23
+        Iterable<Vote> allVotes = voteRepository.findVotesByPoll(pollId);
24
+
25
+        //TODO: Implement algorithm to count votes
26
+        return new ResponseEntity<VoteResult>(voteResult, HttpStatus.OK);
27
+    }
28
+}

+ 66
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Datei anzeigen

@@ -0,0 +1,66 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import io.zipcoder.tc_spring_poll_application.exception.ResourceNotFoundException;
5
+import io.zipcoder.tc_spring_poll_application.repositories.PollRepository;
6
+import org.springframework.http.HttpHeaders;
7
+import org.springframework.http.HttpStatus;
8
+import org.springframework.http.ResponseEntity;
9
+import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
11
+
12
+import javax.inject.Inject;
13
+import javax.validation.Valid;
14
+import java.net.URI;
15
+
16
+@RestController
17
+public class PollController {
18
+
19
+    @Inject
20
+    private PollRepository pollRepository;
21
+
22
+    @RequestMapping(value="/polls", method= RequestMethod.GET)
23
+    public ResponseEntity<Iterable<Poll>> getAllPolls() {
24
+        Iterable<Poll> allPolls = pollRepository.findAll();
25
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
26
+    }
27
+
28
+    @RequestMapping(value="/polls", method=RequestMethod.POST)
29
+    public ResponseEntity<?> createPoll(@Valid @RequestBody Poll poll) {
30
+        poll = pollRepository.save(poll);
31
+        HttpHeaders responseHeaders = new HttpHeaders();
32
+        URI newPollUri = ServletUriComponentsBuilder
33
+                .fromCurrentRequest()
34
+                .path("/{id}")
35
+                .buildAndExpand(poll.getId())
36
+                .toUri();
37
+        responseHeaders.setLocation(newPollUri);
38
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
39
+    }
40
+
41
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.GET)
42
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
43
+        Poll p = pollRepository.findOne(pollId);
44
+        return new ResponseEntity<> (p, HttpStatus.OK);
45
+    }
46
+
47
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.PUT)
48
+    public ResponseEntity<?> updatePoll(@Valid @RequestBody Poll poll, @PathVariable Long pollId) {
49
+        // Save the entity
50
+        Poll p = pollRepository.save(poll);
51
+        return new ResponseEntity<>(HttpStatus.OK);
52
+    }
53
+
54
+    @RequestMapping(value="/polls/{pollId}", method=RequestMethod.DELETE)
55
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
56
+        pollRepository.delete(pollId);
57
+        return new ResponseEntity<>(HttpStatus.OK);
58
+    }
59
+
60
+    void verifyPoll(Long pollId) throws ResourceNotFoundException {
61
+        Poll poll = pollRepository.findOne(pollId);
62
+        if (poll == null){
63
+            throw new ResourceNotFoundException("Poll with id "+ pollId + " not found");
64
+        }
65
+    }
66
+}

+ 38
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java Datei anzeigen

@@ -0,0 +1,38 @@
1
+package io.zipcoder.tc_spring_poll_application.controller;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import io.zipcoder.tc_spring_poll_application.repositories.VoteRepository;
5
+import org.springframework.http.HttpHeaders;
6
+import org.springframework.http.HttpStatus;
7
+import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.*;
9
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
10
+
11
+import javax.inject.Inject;
12
+
13
+@RestController
14
+public class VoteController {
15
+    @Inject
16
+    private VoteRepository voteRepository;
17
+
18
+    @RequestMapping(value = "/polls/{pollId}/votes", method = RequestMethod.POST)
19
+    public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
20
+            vote) {
21
+        vote = voteRepository.save(vote);
22
+        // Set the headers for the newly created resource
23
+        HttpHeaders responseHeaders = new HttpHeaders();
24
+        responseHeaders.setLocation(ServletUriComponentsBuilder.
25
+                fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
26
+        return new ResponseEntity<>(null, responseHeaders, HttpStatus.CREATED);
27
+    }
28
+
29
+    @RequestMapping(value="/polls/votes", method=RequestMethod.GET)
30
+    public Iterable<Vote> getAllVotes() {
31
+        return voteRepository.findAll();
32
+    }
33
+
34
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
35
+    public Iterable<Vote> getVote(@PathVariable Long pollId) {
36
+        return voteRepository.findVotesByPoll(pollId);
37
+    }
38
+}

+ 34
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Option.java Datei anzeigen

@@ -0,0 +1,34 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.Column;
4
+import javax.persistence.Entity;
5
+import javax.persistence.GeneratedValue;
6
+import javax.persistence.Id;
7
+
8
+@Entity
9
+public class Option {
10
+
11
+    @Id
12
+    @GeneratedValue
13
+    @Column(name = "OPTION_ID")
14
+    private Long id;
15
+
16
+    @Column(name = "OPTION_VALUE")
17
+    private String option;
18
+
19
+    public Long getId() {
20
+        return id;
21
+    }
22
+
23
+    public void setId(long id) {
24
+        this.id = id;
25
+    }
26
+
27
+    public String getOption() {
28
+        return option;
29
+    }
30
+
31
+    public void setOption(String option) {
32
+        this.option = option;
33
+    }
34
+}

+ 50
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Poll.java Datei anzeigen

@@ -0,0 +1,50 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import org.hibernate.validator.constraints.NotEmpty;
4
+
5
+import javax.persistence.*;
6
+import javax.validation.constraints.Size;
7
+import java.util.Set;
8
+
9
+@Entity
10
+public class Poll {
11
+
12
+    @Id
13
+    @GeneratedValue
14
+    @Column(name = "POLL_ID")
15
+    private Long id;
16
+
17
+    @Column(name = "QUESTION")
18
+    @NotEmpty
19
+    private String question;
20
+
21
+    @OneToMany(cascade = CascadeType.ALL)
22
+    @JoinColumn(name = "POLL_ID")
23
+    @OrderBy
24
+    @Size(min=2, max=6)
25
+    private Set<Option> options;
26
+
27
+    public Long getId() {
28
+        return id;
29
+    }
30
+
31
+    public void setId(Long id) {
32
+        this.id = id;
33
+    }
34
+
35
+    public String getQuestion() {
36
+        return question;
37
+    }
38
+
39
+    public void setQuestion(String question) {
40
+        this.question = question;
41
+    }
42
+
43
+    public Set<Option> getOptions() {
44
+        return options;
45
+    }
46
+
47
+    public void setOptions(Set<Option> options) {
48
+        this.options = options;
49
+    }
50
+}

+ 32
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/domain/Vote.java Datei anzeigen

@@ -0,0 +1,32 @@
1
+package io.zipcoder.tc_spring_poll_application.domain;
2
+
3
+import javax.persistence.*;
4
+
5
+@Entity
6
+public class Vote {
7
+
8
+    @Id
9
+    @GeneratedValue
10
+    @Column(name = "VOTE_ID")
11
+    private Long id;
12
+
13
+    @ManyToOne
14
+    @JoinColumn(name = "OPTION_ID")
15
+    private Option option;
16
+
17
+    public Long getId() {
18
+        return id;
19
+    }
20
+
21
+    public void setId(Long id) {
22
+        this.id = id;
23
+    }
24
+
25
+    public Option getOption() {
26
+        return option;
27
+    }
28
+
29
+    public void setOption(Option option) {
30
+        this.option = option;
31
+    }
32
+}

+ 19
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java Datei anzeigen

@@ -0,0 +1,19 @@
1
+package io.zipcoder.tc_spring_poll_application.exception;
2
+
3
+import org.springframework.http.HttpStatus;
4
+import org.springframework.web.bind.annotation.ResponseStatus;
5
+
6
+@ResponseStatus(HttpStatus.NOT_FOUND)
7
+public class ResourceNotFoundException extends RuntimeException {
8
+
9
+    public ResourceNotFoundException() {
10
+    }
11
+
12
+    public ResourceNotFoundException(String message) {
13
+        super(message);
14
+    }
15
+
16
+    public ResourceNotFoundException(String message, Throwable cause) {
17
+        super(message, cause);
18
+    }
19
+}

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Option;
4
+import org.springframework.data.repository.CrudRepository;
5
+
6
+public interface OptionRepository extends CrudRepository<Option, Long> {
7
+}

+ 7
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Datei anzeigen

@@ -0,0 +1,7 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Poll;
4
+import org.springframework.data.repository.CrudRepository;
5
+
6
+public interface PollRepository extends CrudRepository<Poll, Long> {
7
+}

+ 14
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Datei anzeigen

@@ -0,0 +1,14 @@
1
+package io.zipcoder.tc_spring_poll_application.repositories;
2
+
3
+import io.zipcoder.tc_spring_poll_application.domain.Vote;
4
+import org.springframework.data.jpa.repository.Query;
5
+import org.springframework.data.repository.CrudRepository;
6
+
7
+public interface VoteRepository extends CrudRepository<Vote, Long> {
8
+    @Query(value = "SELECT v.* " +
9
+            "FROM Option o, Vote v " +
10
+            "WHERE o.POLL_ID = ?1 " +
11
+            "AND v.OPTION_ID = o.OPTION_ID", nativeQuery = true)
12
+    public Iterable<Vote> findVotesByPoll(Long pollId);
13
+}
14
+

+ 89
- 0
src/main/resources/import.sql Datei anzeigen

@@ -0,0 +1,89 @@
1
+insert into poll (poll_id, question) values (1, 'Where are you?');
2
+
3
+insert into option (option_id, option_value, poll_id) values (1, 'At Work', 1);
4
+insert into option (option_id, option_value, poll_id) values (2, 'At Home', 1);
5
+insert into option (option_id, option_value, poll_id) values (3, 'Neither', 1);
6
+
7
+insert into poll (poll_id, question) values (2, 'Where would you go?');
8
+
9
+insert into option (option_id, option_value, poll_id) values (4, 'Beach', 2);
10
+insert into option (option_id, option_value, poll_id) values (5, 'Mountains', 2);
11
+insert into option (option_id, option_value, poll_id) values (6, 'Lake', 2);
12
+
13
+insert into poll (poll_id, question) values (3, 'What is your favorite time of day?');
14
+
15
+insert into option (option_id, option_value, poll_id) values (7, 'Morning', 3);
16
+insert into option (option_id, option_value, poll_id) values (8, 'Afternoon', 3);
17
+insert into option (option_id, option_value, poll_id) values (9, 'Night', 3);
18
+
19
+insert into poll (poll_id, question) values (4, 'What is your favorite sport');
20
+
21
+insert into option (option_id, option_value, poll_id) values (10, 'Baseball', 4);
22
+insert into option (option_id, option_value, poll_id) values (11, 'Football', 4);
23
+insert into option (option_id, option_value, poll_id) values (12, 'Soccer', 4);
24
+
25
+insert into poll (poll_id, question) values (5, 'What operating system do you prefer?');
26
+
27
+insert into option (option_id, option_value, poll_id) values (13, 'OS', 5);
28
+insert into option (option_id, option_value, poll_id) values (14, 'Windows', 5);
29
+insert into option (option_id, option_value, poll_id) values (15, 'Other', 5);
30
+
31
+insert into poll (poll_id, question) values (6, 'How many languages do you speak?');
32
+
33
+insert into option (option_id, option_value, poll_id) values (16, 'One', 6);
34
+insert into option (option_id, option_value, poll_id) values (17, 'Two', 6);
35
+insert into option (option_id, option_value, poll_id) values (18, 'More than two', 6);
36
+
37
+insert into poll (poll_id, question) values (7, 'What operating system do you have on your phone');
38
+
39
+insert into option (option_id, option_value, poll_id) values (19, 'Andriod', 7);
40
+insert into option (option_id, option_value, poll_id) values (20, 'iOS', 7);
41
+insert into option (option_id, option_value, poll_id) values (21, 'Other', 7);
42
+
43
+insert into poll (poll_id, question) values (8, 'What meal of the day is your favorite?');
44
+
45
+insert into option (option_id, option_value, poll_id) values (22, 'Breakfast', 8);
46
+insert into option (option_id, option_value, poll_id) values (23, 'Lunch', 8);
47
+insert into option (option_id, option_value, poll_id) values (24, 'Dinner', 8);
48
+
49
+insert into poll (poll_id, question) values (9, 'Highest level of education');
50
+
51
+insert into option (option_id, option_value, poll_id) values (25, 'High School', 9);
52
+insert into option (option_id, option_value, poll_id) values (26, 'Bachelors', 9);
53
+insert into option (option_id, option_value, poll_id) values (27, 'Masters', 9);
54
+
55
+insert into poll (poll_id, question) values (10, 'Coding is the future');
56
+
57
+insert into option (option_id, option_value, poll_id) values (28, 'Disagree', 10);
58
+insert into option (option_id, option_value, poll_id) values (29, 'Agree', 10);
59
+insert into option (option_id, option_value, poll_id) values (30, 'Undecided', 10);
60
+
61
+insert into poll (poll_id, question) values (11, 'Do you prefer cats or dogs?');
62
+
63
+insert into option (option_id, option_value, poll_id) values (31, 'Cats', 11);
64
+insert into option (option_id, option_value, poll_id) values (32, 'Dogs', 11);
65
+insert into option (option_id, option_value, poll_id) values (33, 'Neither', 11);
66
+
67
+insert into poll (poll_id, question) values (12, 'Do you enjoy going to the movies?');
68
+
69
+insert into option (option_id, option_value, poll_id) values (34, 'Yes', 12);
70
+insert into option (option_id, option_value, poll_id) values (35, 'No', 12);
71
+insert into option (option_id, option_value, poll_id) values (36, 'Sometimes', 12);
72
+
73
+insert into poll (poll_id, question) values (13, 'Do you plan to take a vacation this year?');
74
+
75
+insert into option (option_id, option_value, poll_id) values (37, 'Yes', 13);
76
+insert into option (option_id, option_value, poll_id) values (38, 'No', 13);
77
+insert into option (option_id, option_value, poll_id) values (39, 'Unsure', 13);
78
+
79
+insert into poll (poll_id, question) values (14, 'What is the planet that comes after the Earth?');
80
+
81
+insert into option (option_id, option_value, poll_id) values (40, 'Saturn', 14);
82
+insert into option (option_id, option_value, poll_id) values (41, 'Jupiter', 14);
83
+insert into option (option_id, option_value, poll_id) values (42, 'Mars', 14);
84
+
85
+insert into poll (poll_id, question) values (15, 'Which is not a computer programming language?');
86
+
87
+insert into option (option_id, option_value, poll_id) values (43, 'JavaScript', 15);
88
+insert into option (option_id, option_value, poll_id) values (44, 'Java', 15);
89
+insert into option (option_id, option_value, poll_id) values (45, 'JavaNow', 15);

+ 2
- 0
src/main/resources/messages.properties Datei anzeigen

@@ -0,0 +1,2 @@
1
+NotEmpty.poll.question=Question is a required field
2
+Size.poll.options=Options must be greater than {2} and less than {1}