Kaynağa Gözat

Merge 237fdc4da5aca83f666946eb9882b55a3fb2ec7d into f91a622cc731197181dd1b1e4b17c9bcb450ae8a

SupaGrammer 8 yıl önce
ebeveyn
işleme
91237c071f
No account linked to committer's email

+ 1
- 1
README.md Dosyayı Görüntüle

@@ -627,7 +627,7 @@ Size.poll.options=Options must be greater than {2} and less than {1}
627 627
 
628 628
 * Create a `src/main/resource/import.sql` file with _DML statements_ for populating the database upon bootstrap. The `import.sql` should insert at least 15 polls, each with 3 or more options.
629 629
 	* Below is an example of `SQL` statements for creating a single poll with only one option.
630
-	
630
+	//DML = data manipulation language statements
631 631
 		* Poll Creation
632 632
 		
633 633
 			```sql

+ 5
- 1
pom.xml Dosyayı Görüntüle

@@ -37,12 +37,16 @@
37 37
             <artifactId>hsqldb</artifactId>
38 38
             <scope>runtime</scope>
39 39
         </dependency>
40
-
41 40
         <dependency>
42 41
             <groupId>javax.inject</groupId>
43 42
             <artifactId>javax.inject</artifactId>
44 43
             <version>1</version>
45 44
         </dependency>
45
+        <dependency>
46
+            <groupId>com.mangofactory</groupId>
47
+            <artifactId>swagger-springmvc</artifactId>
48
+            <version>1.0.2</version>
49
+        </dependency>
46 50
     </dependencies>
47 51
 
48 52
 

+ 48
- 0
src/main/java/dtos/ComputeResultController.java Dosyayı Görüntüle

@@ -0,0 +1,48 @@
1
+package dtos;
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.HttpStatus;
6
+import org.springframework.http.ResponseEntity;
7
+import org.springframework.web.bind.annotation.RequestMapping;
8
+import org.springframework.web.bind.annotation.RequestMethod;
9
+import org.springframework.web.bind.annotation.RequestParam;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import javax.inject.Inject;
13
+import java.util.HashMap;
14
+import java.util.Map;
15
+
16
+@RestController
17
+public class ComputeResultController {
18
+    private final VoteRepository voteRepository;
19
+
20
+    @Inject
21
+    public ComputeResultController(VoteRepository voteRepository) {
22
+        this.voteRepository = voteRepository;
23
+    }
24
+
25
+    @RequestMapping(value = "/computeresult", method = RequestMethod.GET)
26
+    public ResponseEntity<?> computeResult(@RequestParam Long pollId) {
27
+        VoteResult voteResult = new VoteResult();
28
+        Iterable<Vote> allVotes = voteRepository.findVotesByPoll(pollId);
29
+        int totalVotes = 0;
30
+        Map<Long, OptionCount> tempMap = new HashMap<Long, OptionCount>();
31
+        for(Vote v : allVotes) {
32
+            totalVotes ++;
33
+            // Get the OptionCount corresponding to this Option
34
+            OptionCount optionCount = tempMap.get(v.getOption().getId());
35
+            if(optionCount == null) {
36
+                optionCount = new OptionCount();
37
+                optionCount.setOptionId(v.getOption().getId());
38
+                tempMap.put(v.getOption().getId(), optionCount);
39
+            }
40
+
41
+            optionCount.setCount(optionCount.getCount()+1);
42
+        }
43
+
44
+        voteResult.setTotalVotes(totalVotes);
45
+        voteResult.setResults(tempMap.values());
46
+        return new ResponseEntity<VoteResult>(voteResult, HttpStatus.OK);
47
+    }
48
+}

+ 22
- 0
src/main/java/dtos/OptionCount.java Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

@@ -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
+}

+ 41
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/Domain/Option.java Dosyayı Görüntüle

@@ -0,0 +1,41 @@
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
+
9
+/**
10
+ * @POJO
11
+ * I am POJO JOJO
12
+ */
13
+
14
+@Entity
15
+public class Option {
16
+
17
+    @Id
18
+    @GeneratedValue
19
+    @Column(name = "OPTION_ID")
20
+    private long id;
21
+
22
+    @Column(name = "OPTION_VALUE")
23
+    private String value;
24
+
25
+    public long getId() {
26
+        return id;
27
+    }
28
+
29
+    public void setId(long id) {
30
+        this.id = id;
31
+    }
32
+
33
+    public String getValue() {
34
+        return value;
35
+    }
36
+
37
+    public void setValue(String value) {
38
+        this.value = value;
39
+    }
40
+}
41
+

+ 52
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/Domain/Poll.java Dosyayı Görüntüle

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

+ 37
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/Domain/Vote.java Dosyayı Görüntüle

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

+ 73
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/PollController.java Dosyayı Görüntüle

@@ -0,0 +1,73 @@
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
+    private final PollRepository pollRepository;
20
+
21
+    @Inject
22
+    public PollController(PollRepository pollRepository) {
23
+        this.pollRepository = pollRepository;
24
+    }
25
+
26
+    @RequestMapping(value = "/polls", method = RequestMethod.GET)
27
+    public ResponseEntity<Iterable<Poll>> getAllPolls() {
28
+        Iterable<Poll> allPolls = pollRepository.findAll();
29
+        return new ResponseEntity<>(allPolls, HttpStatus.OK);
30
+    }
31
+
32
+    @RequestMapping(value = "/polls", method = RequestMethod.POST)
33
+    public ResponseEntity<?> createPoll(@Valid @RequestBody Poll poll) {
34
+        poll = pollRepository.save(poll);
35
+        HttpHeaders headers = new HttpHeaders();
36
+        URI newPollUri = ServletUriComponentsBuilder
37
+                .fromCurrentRequest()
38
+                .path("/{id}")
39
+                .buildAndExpand(poll.getId())
40
+                .toUri();
41
+        headers.setLocation(newPollUri);
42
+        return new ResponseEntity<>(headers, HttpStatus.CREATED);
43
+    }
44
+
45
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.DELETE)
46
+    public ResponseEntity<?> deletePoll(@PathVariable Long pollId) {
47
+        verifyPoll(pollId);
48
+        pollRepository.delete(pollId);
49
+        return new ResponseEntity<>(HttpStatus.OK);
50
+    }
51
+
52
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.PUT)
53
+    public ResponseEntity<?> updatePoll(@Valid @RequestBody Poll poll, @PathVariable Long pollId) {
54
+        verifyPoll(pollId);
55
+        // Save the entity
56
+        Poll p = pollRepository.save(poll);
57
+        return new ResponseEntity<>(HttpStatus.OK);
58
+    }
59
+
60
+    @RequestMapping(value = "/polls/{pollId}", method = RequestMethod.GET)
61
+    public ResponseEntity<?> getPoll(@PathVariable Long pollId) {
62
+        verifyPoll(pollId);
63
+        Poll p = pollRepository.findOne(pollId);
64
+        return new ResponseEntity<>(p, HttpStatus.OK);
65
+    }
66
+
67
+    private void verifyPoll(Long pollId) {
68
+        Poll p = pollRepository.findOne(pollId);
69
+        if(p == null){
70
+            throw new ResourceNotFoundException("Poll with id " + pollId + " does not exist");
71
+        }
72
+    }
73
+ }

+ 37
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/controller/VoteController.java Dosyayı Görüntüle

@@ -0,0 +1,37 @@
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
+
16
+    private final VoteRepository voteRepository;
17
+
18
+    @Inject
19
+    public VoteController(VoteRepository voteRepository) {
20
+        this.voteRepository = voteRepository;
21
+    }
22
+
23
+    @RequestMapping(value = "/polls/{pollId}/votes", method = RequestMethod.POST)
24
+    public ResponseEntity<?> createVote(@PathVariable Long pollId, @RequestBody Vote
25
+            vote) {
26
+        vote = voteRepository.save(vote);
27
+        // Set the headers for the newly created resource
28
+        HttpHeaders responseHeaders = new HttpHeaders();
29
+        responseHeaders.setLocation(ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(vote.getId()).toUri());
30
+        return new ResponseEntity<>(responseHeaders, HttpStatus.CREATED);
31
+    }
32
+
33
+    @RequestMapping(value="/polls/{pollId}/votes", method=RequestMethod.GET)
34
+    public Iterable<Vote> getAllVotes(@PathVariable Long pollId) {
35
+        return voteRepository.findVotesByPoll(pollId);
36
+    }
37
+}

+ 60
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ErrorDetail.java Dosyayı Görüntüle

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

+ 63
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/RestExceptionHandler.java Dosyayı Görüntüle

@@ -0,0 +1,63 @@
1
+package io.zipcoder.tc_spring_poll_application.dto.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 javax.inject.Inject;
12
+import javax.servlet.http.HttpServletRequest;
13
+import java.util.ArrayList;
14
+import java.util.Date;
15
+import java.util.List;
16
+
17
+@ControllerAdvice
18
+public class RestExceptionHandler {
19
+
20
+    private final MessageSource messageSource;
21
+
22
+    @Inject
23
+    public RestExceptionHandler(MessageSource messageSource) {
24
+        this.messageSource = messageSource;
25
+    }
26
+
27
+    @ExceptionHandler(ResourceNotFoundException.class)
28
+    public ResponseEntity<?> handleResourceNotFoundException(ResourceNotFoundException rnfe, HttpServletRequest request) {
29
+        ErrorDetail errorDetail = new ErrorDetail();
30
+        errorDetail.setTimeStamp(new Date().getTime());
31
+        errorDetail.setStatus(HttpStatus.NOT_FOUND.value());
32
+        errorDetail.setTitle("Resource Not Found");
33
+        errorDetail.setDetail(rnfe.getMessage());
34
+        errorDetail.setDeveloperMessage(rnfe.getClass().getName());
35
+        return new ResponseEntity<>(errorDetail, HttpStatus.NOT_FOUND);
36
+    }
37
+
38
+    @ExceptionHandler(MethodArgumentNotValidException.class)
39
+    public ResponseEntity<?>
40
+    handleValidationError(MethodArgumentNotValidException manve,HttpServletRequest request){
41
+        ErrorDetail errorDetail = new ErrorDetail();
42
+        errorDetail.setTitle("Bad Request");
43
+        errorDetail.setDetail(manve.getMessage());
44
+        errorDetail.setDeveloperMessage(manve.getClass().getName());
45
+        errorDetail.setStatus(HttpStatus.BAD_REQUEST.value());
46
+        errorDetail.setTimeStamp(new Date().getTime());
47
+
48
+        List<FieldError> fieldErrors =  manve.getBindingResult().getFieldErrors();
49
+        for(FieldError fe : fieldErrors) {
50
+
51
+            List<ValidationError> validationErrorList = errorDetail.getErrors().get(fe.getField());
52
+            if(validationErrorList == null) {
53
+                validationErrorList = new ArrayList<>();
54
+                errorDetail.getErrors().put(fe.getField(), validationErrorList);
55
+            }
56
+            ValidationError validationError = new ValidationError();
57
+            validationError.setCode(fe.getCode());
58
+            validationError.setMessage(messageSource.getMessage(fe, null));
59
+            validationErrorList.add(validationError);
60
+        }
61
+        return new ResponseEntity<>(errorDetail, null, HttpStatus.BAD_REQUEST);
62
+    }
63
+}

+ 22
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/dto/error/ValidationError.java Dosyayı Görüntüle

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

+ 19
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/exception/ResourceNotFoundException.java Dosyayı Görüntüle

@@ -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
+    private static final long serialVersionUID = 1L;
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
+}

+ 8
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/OptionRepository.java Dosyayı Görüntüle

@@ -0,0 +1,8 @@
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
+
8
+}

+ 8
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/PollRepository.java Dosyayı Görüntüle

@@ -0,0 +1,8 @@
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
+
8
+}

+ 13
- 0
src/main/java/io/zipcoder/tc_spring_poll_application/repositories/VoteRepository.java Dosyayı Görüntüle

@@ -0,0 +1,13 @@
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
+    Iterable<Vote> findVotesByPoll(Long pollId);
13
+}

+ 32
- 0
src/main/resources/import.sql Dosyayı Görüntüle

@@ -0,0 +1,32 @@
1
+			insert into poll (poll_id, question) values (1, 'What is your favorite color?');
2
+			insert into option (option_id, option_value, poll_id) values (1, 'Red', 1);
3
+			insert into poll (poll_id, question) values (2, 'What is your favorite color?');
4
+			insert into option (option_id, option_value, poll_id) values (2, 'Orange', 1);
5
+			insert into poll (poll_id, question) values (3, 'What is your favorite color?');
6
+			insert into option (option_id, option_value, poll_id) values (3, 'Yellow', 1);
7
+			insert into poll (poll_id, question) values (4, 'What is your favorite color?');
8
+			insert into option (option_id, option_value, poll_id) values (4, 'Green', 1);
9
+			insert into poll (poll_id, question) values (5, 'What is your favorite color?');
10
+			insert into option (option_id, option_value, poll_id) values (5, 'Blue', 1);
11
+			insert into poll (poll_id, question) values (6, 'What is your favorite color?');
12
+			insert into option (option_id, option_value, poll_id) values (6, 'Indigo', 1);
13
+			insert into poll (poll_id, question) values (7, 'What is your favorite color?');
14
+			insert into option (option_id, option_value, poll_id) values (7, 'Violet', 1);
15
+			insert into poll (poll_id, question) values (8, 'What is your favorite color?');
16
+			insert into option (option_id, option_value, poll_id) values (8, 'Magenta', 1);
17
+			insert into poll (poll_id, question) values (9, 'What is your favorite color?');
18
+			insert into option (option_id, option_value, poll_id) values (9, 'Cyan', 1);
19
+			insert into poll (poll_id, question) values (10, 'What is your favorite color?');
20
+			insert into option (option_id, option_value, poll_id) values (10, 'Purple', 1);
21
+			insert into poll (poll_id, question) values (11, 'What is your favorite color?');
22
+			insert into option (option_id, option_value, poll_id) values (11, 'Pink', 1);
23
+			insert into poll (poll_id, question) values (12, 'What is your favorite color?');
24
+			insert into option (option_id, option_value, poll_id) values (12, 'Grey', 1);
25
+			insert into poll (poll_id, question) values (13, 'What is your favorite color?');
26
+			insert into option (option_id, option_value, poll_id) values (13, 'Black', 1);
27
+			insert into poll (poll_id, question) values (14, 'What is your favorite color?');
28
+			insert into option (option_id, option_value, poll_id) values (14, 'White', 1);
29
+			insert into poll (poll_id, question) values (15, 'What is your favorite color?');
30
+			insert into option (option_id, option_value, poll_id) values (15, 'Silver', 1);
31
+
32
+

+ 2
- 0
src/main/resources/messages.properties Dosyayı Görüntüle

@@ -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}