Skip to content

Commit

Permalink
fix: backend_java test time dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
blue86321 committed Feb 20, 2024
1 parent d12d43b commit a6b61ff
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -83,8 +86,8 @@ class ElectionRelatedTests {
Elections election = Elections.builder()
.university(university)
.electionName("SCU club president election")
.startTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2023-05-20 12:00:00.000000"))
.endTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2023-06-20 12:00:00.000000"))
.startTime(Date.from(Instant.now().minus(3, ChronoUnit.DAYS)))
.endTime(Date.from(Instant.now().plus(3, ChronoUnit.DAYS)))
.build();
Positions position = Positions.builder()
.election(election)
Expand Down Expand Up @@ -187,8 +190,8 @@ class ElectionTestCases {
ElectionParams newElectionParams = ElectionParams.builder()
.universityId(university.getId())
.electionName("Another elections")
.startTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2023-05-20 12:00:00.000000"))
.endTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").parse("2023-06-20 12:00:00.000000"))
.startTime(Date.from(Instant.now().minus(3, ChronoUnit.DAYS)))
.endTime(Date.from(Instant.now().plus(3, ChronoUnit.DAYS)))
.build();

Long newElectionId;
Expand Down Expand Up @@ -694,7 +697,6 @@ public void postVotesNoLogin() throws Exception {
@Test
public void postVotesUserDiffUniversity() throws Exception {
String token = loginHelper(userAnotherUniv.getEmail());
mapper.writeValueAsString(newVoteParams);
mvc.perform(MockMvcRequestBuilders.post("/votes/")
.header("Authorization", "Bearer " + token)
.content(mapper.writeValueAsString(newVoteParams))
Expand Down

0 comments on commit a6b61ff

Please sign in to comment.