Skip to content

Commit

Permalink
Added unit tests and excluding exception package from sonar.
Browse files Browse the repository at this point in the history
  • Loading branch information
chris.ditcher authored and chris.ditcher committed Aug 10, 2023
1 parent 22583fc commit 05bf5c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
src/main/java/ca/bc/gov/educ/api/gradstudent/model/**,
src/main/java/ca/bc/gov/educ/api/gradstudent/messaging/**,
src/main/java/ca/bc/gov/educ/api/gradstudent/scheduler/**,
src/main/java/ca/bc/gov/educ/api/gradstudent/util/**
src/main/java/ca/bc/gov/educ/api/gradstudent/util/**,
src/main/java/ca/bc/gov/educ/api/gradstudent/exception/**
</sonar.exclusions>
<sonar.junit.exclusions>
src/main/java/ca/bc/gov/educ/api/gradstudent/messaging/**,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ca.bc.gov.educ.api.gradstudent.service;

import ca.bc.gov.educ.api.gradstudent.exception.EntityNotFoundException;
import ca.bc.gov.educ.api.gradstudent.messaging.NatsConnection;
import ca.bc.gov.educ.api.gradstudent.messaging.jetstream.FetchGradStatusSubscriber;
import ca.bc.gov.educ.api.gradstudent.messaging.jetstream.Publisher;
Expand Down Expand Up @@ -46,7 +47,7 @@

import static ca.bc.gov.educ.api.gradstudent.service.GraduationStatusService.PAGE_SIZE;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.openMocks;
Expand Down Expand Up @@ -94,6 +95,25 @@ public void tearDown() {

}

@Test
public void testHasStudentGraduated_GivenValidProgramCompletionDate_ExpectTrue() throws EntityNotFoundException {
UUID studentID = UUID.randomUUID();
GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
graduationStatusEntity.setProgramCompletionDate(new java.util.Date());
when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
boolean result = graduationStatusService.hasStudentGraduated(studentID);
assertTrue(result);
}

@Test
public void testHasStudentGraduated_GivenNoProgramCompletionDate_ExpectFalse() throws EntityNotFoundException {
UUID studentID = UUID.randomUUID();
GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
boolean result = graduationStatusService.hasStudentGraduated(studentID);
assertFalse(result);
}

@Test
public void testGetGraduationStatusForAlgorithm() {
// ID
Expand Down

0 comments on commit 05bf5c1

Please sign in to comment.