Skip to content

Commit

Permalink
Added job_should_have_at_least_one_shift unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudarvishian committed May 9, 2024
1 parent a2b0d75 commit 8d14eac
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test/java/com/zenjob/challenge/JobServiceTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.zenjob.challenge;

import com.zenjob.challenge.entity.Job;
import com.zenjob.challenge.service.IJobService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand All @@ -15,14 +16,23 @@ public class JobServiceTests {
@Autowired
private IJobService jobService;

@Test
public void job_should_have_at_least_one_shift() {
LocalDate startDate = LocalDate.now();
LocalDate endDate = LocalDate.now().plusDays(1);

Job job = jobService.createJob(UUID.randomUUID(), startDate, endDate);

Assertions.assertEquals(1, job.getShifts().size());
}

@Test
public void start_date_cannot_be_in_the_past() {
LocalDate startDate = LocalDate.now().minusDays(10);
LocalDate endDate = LocalDate.now().plusDays(2);

Assertions.assertThrows(IllegalArgumentException.class, () -> {
jobService.createJob(UUID.randomUUID(), startDate, endDate);
});
Assertions.assertThrows(IllegalArgumentException.class, () ->
jobService.createJob(UUID.randomUUID(), startDate, endDate));
}

}

0 comments on commit 8d14eac

Please sign in to comment.