-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rule to shouldCreateHistory method to check if a school's isCan…
…IssueTranscripts property has changed since the last cache.
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
api/src/test/java/ca/bc/gov/educ/api/trax/service/SchoolEventBaseServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package ca.bc.gov.educ.api.trax.service; | ||
|
||
import ca.bc.gov.educ.api.trax.model.dto.institute.School; | ||
import ca.bc.gov.educ.api.trax.model.dto.institute.SchoolDetail; | ||
import ca.bc.gov.educ.api.trax.service.institute.SchoolService; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.openMocks; | ||
|
||
class SchoolEventBaseServiceTest { | ||
|
||
@Mock | ||
private SchoolService schoolService; | ||
private AutoCloseable closeable; | ||
|
||
@InjectMocks | ||
private SchoolEventBaseService<School> schoolEventBaseService = new SchoolCreatedService(schoolService) {}; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
closeable = openMocks(this); | ||
} | ||
|
||
@AfterEach | ||
public void finish() throws Exception { | ||
closeable.close(); | ||
} | ||
|
||
@Test | ||
void shouldCreateHistory_whenSchoolCanIssueTranscriptsChanged() { | ||
School school = new School(); | ||
school.setSchoolId("123"); | ||
school.setCanIssueTranscripts(false); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(true); | ||
when(schoolService.getSchoolDetailByIdFromInstituteApi("123")).thenReturn(schoolDetail); | ||
assertTrue(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
|
||
@Test | ||
void shouldCreateHistory_whenSchoolCanIssueTranscriptsIsTrue() { | ||
School school = new School(); | ||
school.setSchoolId("123"); | ||
school.setCanIssueTranscripts(true); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(true); | ||
when(schoolService.getSchoolDetailByIdFromInstituteApi("123")).thenReturn(schoolDetail); | ||
assertTrue(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
|
||
@Test | ||
void shouldNotCreateHistory_whenSchoolCanIssueTranscriptsIsFalse() { | ||
School school = new School(); | ||
school.setSchoolId("123"); | ||
school.setCanIssueTranscripts(false); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(false); | ||
when(schoolService.getSchoolDetailByIdFromInstituteApi("123")).thenReturn(schoolDetail); | ||
assertFalse(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
} |