diff --git a/api/src/main/java/ca/bc/gov/educ/api/edx/service/v1/EdxUsersService.java b/api/src/main/java/ca/bc/gov/educ/api/edx/service/v1/EdxUsersService.java index 4a98039f..e789e766 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/edx/service/v1/EdxUsersService.java +++ b/api/src/main/java/ca/bc/gov/educ/api/edx/service/v1/EdxUsersService.java @@ -4,7 +4,6 @@ import ca.bc.gov.educ.api.edx.exception.EntityNotFoundException; import ca.bc.gov.educ.api.edx.exception.InvalidPayloadException; import ca.bc.gov.educ.api.edx.exception.errors.ApiError; -import ca.bc.gov.educ.api.edx.mappers.v1.EdxUserMapper; import ca.bc.gov.educ.api.edx.model.v1.*; import ca.bc.gov.educ.api.edx.props.ApplicationProperties; import ca.bc.gov.educ.api.edx.repository.*; @@ -12,6 +11,7 @@ import ca.bc.gov.educ.api.edx.struct.v1.*; import ca.bc.gov.educ.api.edx.utils.TransformUtil; import com.google.common.primitives.Chars; +import jakarta.persistence.EntityExistsException; import lombok.AccessLevel; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -24,11 +24,11 @@ import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import jakarta.persistence.EntityExistsException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.time.LocalDateTime; import java.util.*; +import java.util.stream.Collectors; import static org.springframework.http.HttpStatus.*; @@ -134,11 +134,20 @@ public List findAllDistrictEdxUsers(String districtID) { if(!edxSchools.containsKey(schoolID)){ EdxSchool school = new EdxSchool(); school.setSchoolID(schoolID); - school.setEdxUsers(new ArrayList<>()); + school.setEdxDistrictSchoolUsers(new ArrayList<>()); edxSchools.put(schoolID, school); } - edxSchools.get(schoolID).getEdxUsers().add(EdxUserMapper.mapper.toStructure(edxUserSchoolEntity.getEdxUserEntity())); + EdxDistrictSchoolUserTombstone tomb = new EdxDistrictSchoolUserTombstone(); + var edxUserEntity = edxUserSchoolEntity.getEdxUserEntity(); + tomb.setEdxUserID(edxUserEntity.getEdxUserID().toString()); + tomb.setDigitalIdentityID(edxUserEntity.getDigitalIdentityID().toString()); + tomb.setEmail(edxUserEntity.getEmail()); + tomb.setFullName(edxUserEntity.getFirstName() + " " + edxUserEntity.getLastName()); + var rolesMap = getEdxRolesMap(); + tomb.setSchoolRoles(edxUserSchoolEntity.getEdxUserSchoolRoleEntities().stream().map(edxSchool -> rolesMap.get(edxSchool.getEdxRoleCode()).getLabel()).toList()); + + edxSchools.get(schoolID).getEdxDistrictSchoolUsers().add(tomb); }); return edxSchools.values().stream().toList(); @@ -328,6 +337,10 @@ public List findAllEdxRoles() { return this.getEdxRoleRepository().findAll(); } + public Map getEdxRolesMap() { + return this.getEdxRoleRepository().findAll().stream().collect(Collectors.toMap(EdxRoleEntity::getEdxRoleCode, item -> item)); + } + /** * Activate school user edx user entity. * diff --git a/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxDistrictSchoolUserTombstone.java b/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxDistrictSchoolUserTombstone.java new file mode 100644 index 00000000..e1f427d2 --- /dev/null +++ b/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxDistrictSchoolUserTombstone.java @@ -0,0 +1,28 @@ +package ca.bc.gov.educ.api.edx.struct.v1; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +@JsonIgnoreProperties(ignoreUnknown = true) +public class EdxDistrictSchoolUserTombstone implements Serializable { + private static final long serialVersionUID = 583620260139143932L; + + String edxUserID; + + String digitalIdentityID; + + String fullName; + + private List schoolRoles; + + String email; +} + + + + + diff --git a/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxSchool.java b/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxSchool.java index 8170b18f..9a146d41 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxSchool.java +++ b/api/src/main/java/ca/bc/gov/educ/api/edx/struct/v1/EdxSchool.java @@ -13,6 +13,6 @@ public class EdxSchool implements Serializable { String schoolID; - private List edxUsers; + private List edxDistrictSchoolUsers; } diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/BaseSecureExchangeAPITest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/BaseEdxAPITest.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/BaseSecureExchangeAPITest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/BaseEdxAPITest.java index a43fd276..fe935ac9 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/BaseSecureExchangeAPITest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/BaseEdxAPITest.java @@ -6,13 +6,15 @@ import ca.bc.gov.educ.api.edx.utils.SecureExchangeAPITestUtils; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import lombok.val; import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; +import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -30,11 +32,17 @@ @SpringBootTest(classes = {EdxApiResourceApplication.class}) @ActiveProfiles("test") @AutoConfigureMockMvc -public abstract class BaseSecureExchangeAPITest { +public abstract class BaseEdxAPITest { protected final static ObjectMapper objectMapper = createMapper(); @Autowired protected SecureExchangeAPITestUtils secureExchangeAPITestUtils; + @MockBean + ClientRegistrationRepository clientRegistrationRepository; + + @MockBean + OAuth2AuthorizedClientRepository oAuth2AuthorizedClientRepository; + @BeforeEach public void before() { this.secureExchangeAPITestUtils.cleanDB(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSecureExchangeControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseEdxControllerTest.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSecureExchangeControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseEdxControllerTest.java index c0ae237b..295d19a2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSecureExchangeControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseEdxControllerTest.java @@ -1,12 +1,10 @@ package ca.bc.gov.educ.api.edx.controller; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.struct.v1.SecureExchange; import com.fasterxml.jackson.databind.ObjectMapper; -import java.util.Set; - -public abstract class BaseSecureExchangeControllerTest extends BaseSecureExchangeAPITest { +public abstract class BaseEdxControllerTest extends BaseEdxAPITest { protected String dummySecureExchangeJson() { return "{\"updateUser\":\"TEST\",\"createUser\":\"TEST\",\"secureExchangeStatusCode\":\"OPEN\",\"isReadByExchangeContact\":\"false\",\"isReadByMinistry\":\"false\",\"statusUpdateDate\":\"1952-10-31T00:00:00\",\"updateDate\":\"1952-10-31T00:00:00\",\"createDate\":\"1952-10-31T00:00:00\",\"subject\":\"Hello Student\",\"ministryOwnershipTeamID\":\"b1e0788a-7dab-4b92-af86-c678e411f1e3\",\"contactIdentifier\":\"b1e0788a-7dab-4b92-af86-c678e411f1e4\",\"secureExchangeContactTypeCode\":\"EDXUSER\", \"secureExchangeID\":\"0a004b01-7027-17b1-8170-27cb21100000\"}"; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSagaControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSagaControllerTest.java index 36b408c3..3c0c33e6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSagaControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/BaseSagaControllerTest.java @@ -10,7 +10,7 @@ import java.util.GregorianCalendar; import java.util.UUID; -public abstract class BaseSagaControllerTest extends BaseSecureExchangeControllerTest { +public abstract class BaseSagaControllerTest extends BaseEdxControllerTest { protected String secureExchangeCreateJsonWithMinAndComment(final String ministryOwnershipTeamID) { return "{\"updateUser\":\"TEST\",\"createUser\":\"TEST\",\"isReadByExchangeContact\":\"false\",\"isReadByMinistry\":\"false\",\"secureExchangeStatusCode\":\"OPEN\",\"statusUpdateDate\":\"1952-10-31T00:00:00\",\"subject\":\"Hello Student\",\"ministryOwnershipTeamID\":\"" + ministryOwnershipTeamID + "\",\"contactIdentifier\":\"b1e0788a-7dab-4b92-af86-c678e411f1e4\",\"secureExchangeContactTypeCode\":\"EDXUSER\", \"commentsList\": [{\"staffUserIdentifier\": \"TEST\", \"commentUserName\": \"JACKSON, JAMES\", \"content\": \"This is content\", \"updateUser\":\"TEST\",\"createUser\":\"TEST\"}]}"; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeCommentControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxCommentControllerTest.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeCommentControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxCommentControllerTest.java index 99d941ee..9aa317e2 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeCommentControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxCommentControllerTest.java @@ -25,7 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SecureExchangeCommentControllerTest extends BaseSecureExchangeControllerTest { +class EdxCommentControllerTest extends BaseEdxControllerTest { private static final SecureExchangeEntityMapper mapper = SecureExchangeEntityMapper.mapper; @Autowired private MockMvc mockMvc; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxControllerTest.java similarity index 99% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxControllerTest.java index 1f30a602..50169961 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxControllerTest.java @@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SecureExchangeControllerTest extends BaseSecureExchangeControllerTest { +class EdxControllerTest extends BaseEdxControllerTest { private static final SecureExchangeEntityMapper mapper = SecureExchangeEntityMapper.mapper; @Autowired diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeDocumentControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxDocumentControllerTest.java similarity index 97% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeDocumentControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxDocumentControllerTest.java index 45c17517..b9ea17bb 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeDocumentControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxDocumentControllerTest.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.controller; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.constants.v1.URL; import ca.bc.gov.educ.api.edx.controller.v1.SecureExchangeDocumentController; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeDocumentEntity; @@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SecureExchangeDocumentControllerTest extends BaseSecureExchangeAPITest { +class EdxDocumentControllerTest extends BaseEdxAPITest { @Autowired private MockMvc mvc; @@ -97,7 +97,7 @@ void createDocumentTest() throws Exception { .with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_SECURE_EXCHANGE_DOCUMENT"))) .contentType(MediaType.APPLICATION_JSON) .content(Files.readAllBytes(new ClassPathResource( - "../model/document-req.json", SecureExchangeDocumentControllerTest.class).getFile().toPath())) + "../model/document-req.json", EdxDocumentControllerTest.class).getFile().toPath())) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()) .andDo(print()) @@ -113,7 +113,7 @@ void updateDocumentTest() throws Exception { .with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_SECURE_EXCHANGE_DOCUMENT"))) .contentType(MediaType.APPLICATION_JSON) .content(Files.readAllBytes(new ClassPathResource( - "../model/document-req.json", SecureExchangeDocumentControllerTest.class).getFile().toPath())) + "../model/document-req.json", EdxDocumentControllerTest.class).getFile().toPath())) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()) .andDo(print()) @@ -233,7 +233,7 @@ void createDocumentWithInvalidFileSizeTest() throws Exception { .with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_SECURE_EXCHANGE_DOCUMENT"))) .contentType(MediaType.APPLICATION_JSON) .content(Files.readAllBytes(new ClassPathResource( - "../model/document-req-invalid-filesize.json", SecureExchangeDocumentControllerTest.class).getFile().toPath())) + "../model/document-req-invalid-filesize.json", EdxDocumentControllerTest.class).getFile().toPath())) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()) .andDo(print()) @@ -247,7 +247,7 @@ void createDocumentWithoutDocumentDataTest() throws Exception { .with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_SECURE_EXCHANGE_DOCUMENT"))) .contentType(MediaType.APPLICATION_JSON) .content(Files.readAllBytes(new ClassPathResource( - "../model/document-req-without-doc-data.json", SecureExchangeDocumentControllerTest.class).getFile().toPath())) + "../model/document-req-without-doc-data.json", EdxDocumentControllerTest.class).getFile().toPath())) .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest()) .andDo(print()); diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeNoteControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxNoteControllerTest.java similarity index 99% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeNoteControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxNoteControllerTest.java index 5c41e768..b68b2fea 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeNoteControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxNoteControllerTest.java @@ -9,6 +9,7 @@ import ca.bc.gov.educ.api.edx.repository.SecureExchangeRequestRepository; import ca.bc.gov.educ.api.edx.struct.v1.SecureExchangeNote; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.transaction.Transactional; import org.hamcrest.Matchers; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -17,7 +18,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; -import jakarta.transaction.Transactional; import java.util.HashSet; import java.util.UUID; @@ -26,7 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SecureExchangeNoteControllerTest extends BaseSecureExchangeControllerTest { +class EdxNoteControllerTest extends BaseEdxControllerTest { private static final SecureExchangeNoteMapper noteMapper = SecureExchangeNoteMapper.mapper; private static final SecureExchangeEntityMapper exchangeMapper = SecureExchangeEntityMapper.mapper; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStatsControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStatsControllerTest.java index 6e63b529..bb38178a 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStatsControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStatsControllerTest.java @@ -1,13 +1,5 @@ package ca.bc.gov.educ.api.edx.controller; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import ca.bc.gov.educ.api.edx.constants.v1.URL; import ca.bc.gov.educ.api.edx.controller.v1.EdxStatsController; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; @@ -15,11 +7,6 @@ import ca.bc.gov.educ.api.edx.rest.RestUtils; import ca.bc.gov.educ.api.edx.struct.v1.District; import ca.bc.gov.educ.api.edx.struct.v1.School; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -28,7 +15,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.servlet.MockMvc; -class EdxStatsControllerTest extends BaseSecureExchangeControllerTest { +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +class EdxStatsControllerTest extends BaseEdxControllerTest { @Autowired private MockMvc mockMvc; @Autowired diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeStudentControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStudentControllerTest.java similarity index 99% rename from api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeStudentControllerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStudentControllerTest.java index 44d812fa..df56dadf 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/SecureExchangeStudentControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxStudentControllerTest.java @@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SecureExchangeStudentControllerTest extends BaseSecureExchangeControllerTest { +class EdxStudentControllerTest extends BaseEdxControllerTest { private static final SecureExchangeEntityMapper mapper = SecureExchangeEntityMapper.mapper; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxUsersControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxUsersControllerTest.java index f90bd87e..263fd2db 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxUsersControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/controller/EdxUsersControllerTest.java @@ -12,9 +12,9 @@ import lombok.val; import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +22,6 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; -import java.lang.reflect.Array; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.util.*; @@ -34,7 +33,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -class EdxUsersControllerTest extends BaseSecureExchangeControllerTest { +class EdxUsersControllerTest extends BaseEdxControllerTest { @Autowired private MockMvc mockMvc; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/model/SecureExchangeDocRequirementEntityJsonTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/model/SecureExchangeDocRequirementEntityJsonTests.java index 8fd52b62..16703c28 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/model/SecureExchangeDocRequirementEntityJsonTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/model/SecureExchangeDocRequirementEntityJsonTests.java @@ -8,6 +8,9 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.json.JacksonTester; import org.springframework.boot.test.json.JsonContent; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; +import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -22,6 +25,10 @@ @SpringBootTest @ActiveProfiles("test") class SecureExchangeDocRequirementEntityJsonTests { + @MockBean + ClientRegistrationRepository clientRegistrationRepository; + @MockBean + OAuth2AuthorizedClientRepository oAuth2AuthorizedClientRepository; @Autowired private JacksonTester jsonTester; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictSecureExchangeCommentOrchestratorTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictEdxCommentOrchestratorTest.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictSecureExchangeCommentOrchestratorTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictEdxCommentOrchestratorTest.java index 1e6756b5..39beb142 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictSecureExchangeCommentOrchestratorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictEdxCommentOrchestratorTest.java @@ -38,11 +38,8 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -class EdxDistrictSecureExchangeCommentOrchestratorTest extends BaseSagaControllerTest { +class EdxDistrictEdxCommentOrchestratorTest extends BaseSagaControllerTest { - /** - * The Repository. - */ @Autowired SagaRepository sagaRepository; /** diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictUserActivationInviteOrchestratorTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictUserActivationInviteOrchestratorTest.java index 655c1e11..dba0357d 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictUserActivationInviteOrchestratorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxDistrictUserActivationInviteOrchestratorTest.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.orchestrator; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.constants.EventOutcome; import ca.bc.gov.educ.api.edx.constants.EventType; import ca.bc.gov.educ.api.edx.constants.SagaEnum; @@ -38,7 +38,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -class EdxDistrictUserActivationInviteOrchestratorTest extends BaseSecureExchangeAPITest { +class EdxDistrictUserActivationInviteOrchestratorTest extends BaseEdxAPITest { /** diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewSecureExchangeOrchestratorTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewEdxOrchestratorTest.java similarity index 99% rename from api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewSecureExchangeOrchestratorTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewEdxOrchestratorTest.java index ac12be7f..bf8211b6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewSecureExchangeOrchestratorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxNewEdxOrchestratorTest.java @@ -37,7 +37,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -class EdxNewSecureExchangeOrchestratorTest extends BaseSagaControllerTest { +class EdxNewEdxOrchestratorTest extends BaseSagaControllerTest { /** * The Repository. diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolSecureExchangeCommentOrchestratorTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolEdxCommentOrchestratorTest.java similarity index 99% rename from api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolSecureExchangeCommentOrchestratorTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolEdxCommentOrchestratorTest.java index f98f4984..95661181 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolSecureExchangeCommentOrchestratorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolEdxCommentOrchestratorTest.java @@ -19,7 +19,6 @@ import ca.bc.gov.educ.api.edx.struct.v1.SecureExchangeCreateSagaData; import ca.bc.gov.educ.api.edx.utils.JsonUtil; import com.fasterxml.jackson.core.JsonProcessingException; -import lombok.extern.slf4j.Slf4j; import lombok.val; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -40,7 +39,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -class EdxSchoolSecureExchangeCommentOrchestratorTest extends BaseSagaControllerTest { +class EdxSchoolEdxCommentOrchestratorTest extends BaseSagaControllerTest { /** * The Repository. diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolUserActivationInviteOrchestratorTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolUserActivationInviteOrchestratorTest.java index 0d8cb941..f209e998 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolUserActivationInviteOrchestratorTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/orchestrator/EdxSchoolUserActivationInviteOrchestratorTest.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.orchestrator; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.constants.EventOutcome; import ca.bc.gov.educ.api.edx.constants.EventType; import ca.bc.gov.educ.api.edx.constants.SagaEnum; @@ -38,7 +38,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -class EdxSchoolUserActivationInviteOrchestratorTest extends BaseSecureExchangeAPITest { +class EdxSchoolUserActivationInviteOrchestratorTest extends BaseEdxAPITest { /** * The Repository. diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/props/ApplicationPropertiesTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/props/ApplicationPropertiesTest.java index 18a0a76a..c54f9b2c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/props/ApplicationPropertiesTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/props/ApplicationPropertiesTest.java @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.edx.props; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import static org.assertj.core.api.Assertions.assertThat; -class ApplicationPropertiesTest extends BaseSecureExchangeAPITest { +class ApplicationPropertiesTest extends BaseEdxAPITest { @Autowired ApplicationProperties applicationProperties; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/props/EmailPropertiesTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/props/EmailPropertiesTest.java index 45068dcc..76c38d56 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/props/EmailPropertiesTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/props/EmailPropertiesTest.java @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.edx.props; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import static org.assertj.core.api.Assertions.assertThat; -class EmailPropertiesTest extends BaseSecureExchangeAPITest { +class EmailPropertiesTest extends BaseEdxAPITest { @Autowired EmailProperties emailProperties; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/SecureExchangeSchedulerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EdxSchedulerTest.java similarity index 92% rename from api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/SecureExchangeSchedulerTest.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EdxSchedulerTest.java index d77e6c72..971c4b46 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/SecureExchangeSchedulerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EdxSchedulerTest.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.schedulers; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeDocumentEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; import ca.bc.gov.educ.api.edx.repository.DocumentRepository; @@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class SecureExchangeSchedulerTest extends BaseSecureExchangeAPITest { +class EdxSchedulerTest extends BaseEdxAPITest { @Autowired private DocumentRepository repository; @Autowired @@ -45,7 +45,7 @@ public void setUp() throws IOException { final SecureExchangeDocumentEntity document = new DocumentBuilder() .withoutDocumentID() .withData(Files.readAllBytes(new ClassPathResource( - "../model/document-req.json", SecureExchangeSchedulerTest.class).getFile().toPath())) + "../model/document-req.json", EdxSchedulerTest.class).getFile().toPath())) .withSecureExchange(secureExchange) .withTypeCode("CAPASSPORT") .build(); @@ -83,7 +83,7 @@ void testPurgeClosedMessages_GivenMessageIsOlderThanGivenTime_MessageWillBeDelet final SecureExchangeDocumentEntity document = new DocumentBuilder() .withoutDocumentID() .withData(Files.readAllBytes(new ClassPathResource( - "../model/document-req.json", SecureExchangeSchedulerTest.class).getFile().toPath())) + "../model/document-req.json", EdxSchedulerTest.class).getFile().toPath())) .withSecureExchange(secureExchange) .withTypeCode("CAPASSPORT") .build(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EventTaskSchedulerTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EventTaskSchedulerTest.java index 6d254bb0..5cd06cbe 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EventTaskSchedulerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/schedulers/EventTaskSchedulerTest.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.schedulers; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.constants.SagaEnum; import ca.bc.gov.educ.api.edx.model.v1.SagaEntity; import ca.bc.gov.educ.api.edx.model.v1.SagaEventStatesEntity; @@ -24,7 +24,7 @@ import static ca.bc.gov.educ.api.edx.constants.SagaStatusEnum.IN_PROGRESS; import static org.assertj.core.api.Assertions.assertThat; -class EventTaskSchedulerTest extends BaseSecureExchangeAPITest { +class EventTaskSchedulerTest extends BaseEdxAPITest { @Autowired EventTaskScheduler eventTaskScheduler; @Autowired diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/CHESEmailServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/CHESEmailServiceTest.java index 45d6fe74..45df937c 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/CHESEmailServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/CHESEmailServiceTest.java @@ -1,11 +1,11 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.props.ApplicationProperties; +import ca.bc.gov.educ.api.edx.rest.RestUtils; import ca.bc.gov.educ.api.edx.service.v1.CHESEmailService; import ca.bc.gov.educ.api.edx.struct.v1.EmailNotification; -import ca.bc.gov.educ.api.edx.rest.RestUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +13,7 @@ import static org.mockito.Mockito.*; import static org.mockito.MockitoAnnotations.openMocks; -class CHESEmailServiceTest extends BaseSecureExchangeAPITest { +class CHESEmailServiceTest extends BaseEdxAPITest { @Autowired diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeDocumentServiceTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxDocumentServiceTests.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeDocumentServiceTests.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxDocumentServiceTests.java index c763c133..a860c599 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeDocumentServiceTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxDocumentServiceTests.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.exception.EntityNotFoundException; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeDocumentEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; @@ -24,7 +24,7 @@ //import javax.transaction.Transactional; -class SecureExchangeDocumentServiceTests extends BaseSecureExchangeAPITest { +class EdxDocumentServiceTests extends BaseEdxAPITest { @Autowired DocumentService service; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeNoteServiceGetDeleteTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxNoteServiceGetDeleteTests.java similarity index 95% rename from api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeNoteServiceGetDeleteTests.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxNoteServiceGetDeleteTests.java index 9948428f..3a6c52e5 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeNoteServiceGetDeleteTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxNoteServiceGetDeleteTests.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeNoteEntity; import ca.bc.gov.educ.api.edx.props.ApplicationProperties; @@ -13,14 +13,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.fail; import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; -class SecureExchangeNoteServiceGetDeleteTests extends BaseSecureExchangeAPITest { +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.fail; + +class EdxNoteServiceGetDeleteTests extends BaseEdxAPITest { @Autowired SecureExchangeNoteService secureExchangeNoteService; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeServiceTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxServiceTests.java similarity index 98% rename from api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeServiceTests.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxServiceTests.java index aa5e2e19..e59ff3db 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeServiceTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxServiceTests.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.model.v1.MinistryOwnershipTeamEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeCommentEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeContactTypeCodeEntity; @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; -class SecureExchangeServiceTests extends BaseSecureExchangeAPITest { +class EdxServiceTests extends BaseEdxAPITest { @Autowired SecureExchangeService service; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceAddTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceAddTests.java similarity index 96% rename from api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceAddTests.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceAddTests.java index a5df9808..136c2fa8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceAddTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceAddTests.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.mappers.v1.SecureExchangeEntityMapper; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeStudentEntity; @@ -22,7 +22,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; -class SecureExchangeStudentServiceAddTests extends BaseSecureExchangeAPITest { +class EdxStudentServiceAddTests extends BaseEdxAPITest { private static final SecureExchangeEntityMapper mapper = SecureExchangeEntityMapper.mapper; @MockBean diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceGetDeleteTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceGetDeleteTests.java similarity index 96% rename from api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceGetDeleteTests.java rename to api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceGetDeleteTests.java index c923ac53..bb169bd8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/SecureExchangeStudentServiceGetDeleteTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxStudentServiceGetDeleteTests.java @@ -1,6 +1,6 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.mappers.v1.SecureExchangeEntityMapper; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeEntity; import ca.bc.gov.educ.api.edx.model.v1.SecureExchangeStudentEntity; @@ -14,15 +14,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; -import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.fail; import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; import java.util.UUID; -class SecureExchangeStudentServiceGetDeleteTests extends BaseSecureExchangeAPITest { +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.fail; + +class EdxStudentServiceGetDeleteTests extends BaseEdxAPITest { private static final SecureExchangeEntityMapper mapper = SecureExchangeEntityMapper.mapper; diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxUsersServiceTests.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxUsersServiceTests.java index 797cf90a..435ef2c4 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxUsersServiceTests.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EdxUsersServiceTests.java @@ -1,28 +1,29 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; import ca.bc.gov.educ.api.edx.constants.InstituteTypeCode; import ca.bc.gov.educ.api.edx.exception.EntityNotFoundException; import ca.bc.gov.educ.api.edx.model.v1.EdxActivationCodeEntity; import ca.bc.gov.educ.api.edx.model.v1.EdxUserSchoolEntity; +import ca.bc.gov.educ.api.edx.model.v1.EdxUserSchoolRoleEntity; import ca.bc.gov.educ.api.edx.model.v1.MinistryOwnershipTeamEntity; import ca.bc.gov.educ.api.edx.repository.*; +import ca.bc.gov.educ.api.edx.rest.RestUtils; import ca.bc.gov.educ.api.edx.service.v1.EdxUsersService; import ca.bc.gov.educ.api.edx.struct.v1.EdxPrimaryActivationCode; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import java.security.NoSuchAlgorithmException; import java.time.LocalDateTime; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -class EdxUsersServiceTests extends BaseSecureExchangeAPITest { +class EdxUsersServiceTests extends BaseEdxAPITest { @Autowired EdxUsersService service; @@ -39,6 +40,9 @@ class EdxUsersServiceTests extends BaseSecureExchangeAPITest { @Autowired private EdxUserDistrictRepository edxUserDistrictRepository; + @Autowired + private RestUtils restUtils; + @Autowired private EdxRoleRepository edxRoleRepository; @@ -88,6 +92,28 @@ void findEdxUserByDigitalID() { assertThat(edxUserEntities).isNotNull().hasSize(1); } + @Test + void findAllEdxUsersByDistrictID() { + var entity = this.createUserEntity(this.edxUserRepository, this.edxPermissionRepository, this.edxRoleRepository, this.edxUserSchoolRepository, this.edxUserDistrictRepository); + var schoolEntity = getEdxUserSchoolEntity(entity); + schoolEntity.setSchoolID(UUID.randomUUID()); + EdxUserSchoolRoleEntity roleEntity = new EdxUserSchoolRoleEntity(); + roleEntity.setEdxUserSchoolEntity(schoolEntity); + roleEntity.setCreateUser("ABC"); + roleEntity.setEdxRoleCode("EDX_SCHOOL_ADMIN"); + roleEntity.setCreateDate(LocalDateTime.now()); + schoolEntity.getEdxUserSchoolRoleEntities().add(roleEntity); + edxUserSchoolRepository.save(schoolEntity); + + var districtSchoolsMap = new HashMap>(); + var districtID = UUID.randomUUID(); + districtSchoolsMap.put(districtID.toString(), Arrays.asList(schoolEntity.getSchoolID())); + Mockito.when(this.restUtils.getDistrictSchoolsMap()).thenReturn(districtSchoolsMap); + + var edxSchools = this.service.findAllDistrictEdxUsers(districtID.toString()); + assertThat(edxSchools).isNotNull().hasSize(1); + } + @Test void findEdxUserBySchoolID() { var entity = this.createUserEntity(this.edxUserRepository, this.edxPermissionRepository, this.edxRoleRepository, this.edxUserSchoolRepository, this.edxUserDistrictRepository); diff --git a/api/src/test/java/ca/bc/gov/educ/api/edx/service/EmailNotificationServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EmailNotificationServiceTest.java index 0c7901af..8a9d4cd8 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/edx/service/EmailNotificationServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/edx/service/EmailNotificationServiceTest.java @@ -1,10 +1,9 @@ package ca.bc.gov.educ.api.edx.service; -import ca.bc.gov.educ.api.edx.BaseSecureExchangeAPITest; - +import ca.bc.gov.educ.api.edx.BaseEdxAPITest; +import ca.bc.gov.educ.api.edx.rest.RestUtils; import ca.bc.gov.educ.api.edx.service.v1.EmailNotificationService; import ca.bc.gov.educ.api.edx.struct.v1.EmailNotification; -import ca.bc.gov.educ.api.edx.rest.RestUtils; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -18,7 +17,7 @@ import static org.mockito.MockitoAnnotations.openMocks; -class EmailNotificationServiceTest extends BaseSecureExchangeAPITest { +class EmailNotificationServiceTest extends BaseEdxAPITest { @Autowired EmailNotificationService emailNotificationService; diff --git a/api/src/test/resources/application.properties b/api/src/test/resources/application.properties index affb920f..453a7eb3 100644 --- a/api/src/test/resources/application.properties +++ b/api/src/test/resources/application.properties @@ -55,13 +55,6 @@ scheduled.jobs.extract.uncompleted.sagas.cron=- scheduled.jobs.extract.uncompleted.sagas.cron.lockAtLeastFor=55s scheduled.jobs.extract.uncompleted.sagas.cron.lockAtMostFor=58s -#Webclient configuration -spring.security.oauth2.client.registration.edxapi.client-id=blah -spring.security.oauth2.client.registration.edxapi.client-secret=blah -spring.security.oauth2.client.registration.edxapi.authorization-grant-type=blah -spring.security.oauth2.client.provider.edxapi.issuer-uri=https://soam-dev.apps.silver.devops.gov.bc.ca/auth/realms/master -spring.security.oauth2.client.provider.edxapi.token-uri=https://soam-dev.apps.silver.devops.gov.bc.ca/auth/realms/master/protocol/openid-connect/token - apis.endpoints.student.api=blah institute.api.url=blah