-
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. (#393) * Added rule to shouldCreateHistory method to check if a school's isCanIssueTranscripts property has changed since the last cache. * Updated ordering of methods for adding to history
- Loading branch information
Showing
4 changed files
with
84 additions
and
3 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
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
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
72 changes: 72 additions & 0 deletions
72
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,72 @@ | ||
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 java.util.UUID; | ||
|
||
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 { | ||
|
||
private static final String SCHOOL_ID = UUID.randomUUID().toString(); | ||
|
||
@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(SCHOOL_ID); | ||
school.setCanIssueTranscripts(false); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(true); | ||
when(schoolService.getSchoolDetailBySchoolId(UUID.fromString(SCHOOL_ID))).thenReturn(schoolDetail); | ||
assertTrue(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
|
||
@Test | ||
void shouldCreateHistory_whenSchoolCanIssueTranscriptsIsTrue() { | ||
School school = new School(); | ||
school.setSchoolId(SCHOOL_ID); | ||
school.setCanIssueTranscripts(true); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(true); | ||
when(schoolService.getSchoolDetailBySchoolId(UUID.fromString(SCHOOL_ID))).thenReturn(schoolDetail); | ||
assertTrue(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
|
||
@Test | ||
void shouldNotCreateHistory_whenSchoolCanIssueTranscriptsIsFalse() { | ||
School school = new School(); | ||
school.setSchoolId(SCHOOL_ID); | ||
school.setCanIssueTranscripts(false); | ||
SchoolDetail schoolDetail = new SchoolDetail(); | ||
schoolDetail.setCanIssueTranscripts(false); | ||
when(schoolService.getSchoolDetailBySchoolId(UUID.fromString(SCHOOL_ID))).thenReturn(schoolDetail); | ||
assertFalse(schoolEventBaseService.shouldCreateHistory(school)); | ||
} | ||
} |