diff --git a/api/src/test/java/ca/bc/gov/educ/api/institute/controller/v1/SchoolControllerTest.java b/api/src/test/java/ca/bc/gov/educ/api/institute/controller/v1/SchoolControllerTest.java index f258c700..1915d1ff 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/institute/controller/v1/SchoolControllerTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/institute/controller/v1/SchoolControllerTest.java @@ -553,34 +553,6 @@ void testCreateSchool_GivenValidPayload_ShouldReturnStatusOK() throws Exception .andExpect(MockMvcResultMatchers.jsonPath("$.displayNameNoSpecialChars").value(mappedSchool.getDisplayNameNoSpecialChars())); } - @Test - void testCreateSchoolWithSchoolNumberConflict_GivenValidPayload_ShouldReturnStatusCONFLICT() throws Exception { - final DistrictTombstoneEntity dist = this.districtTombstoneRepository.save(this.createDistrictData()); - var existingSchoolEntity = this.createNewSchoolData("99000", "PUBLIC", "DISTONLINE"); - existingSchoolEntity.setDistrictEntity(dist); - schoolRepository.save(existingSchoolEntity); - - var schoolEntity = this.createNewSchoolData("99000", "PUBLIC", "DISTONLINE"); - SchoolMapper map = SchoolMapper.mapper; - - School mappedSchool = map.toStructure(schoolEntity); - - mappedSchool.setDistrictId(dist.getDistrictId().toString()); - mappedSchool.setCreateDate(null); - mappedSchool.setUpdateDate(null); - mappedSchool.setGrades(List.of(createSchoolGrade())); - mappedSchool.setNeighborhoodLearning(List.of(createNeighborhoodLearning())); - mappedSchool.setAddresses(List.of(createSchoolAddress())); - - this.mockMvc.perform(post(URL.BASE_URL_SCHOOL) - .contentType(MediaType.APPLICATION_JSON) - .accept(MediaType.APPLICATION_JSON) - .content(asJsonString(mappedSchool)) - .with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_SCHOOL")))) - .andDo(print()) - .andExpect(status().isConflict()); - } - @Test void testCreateSchool_GivenInvalidPayload_ShouldReturnStatusBadRequest() throws Exception { final var school = this.createSchoolData(); diff --git a/api/src/test/java/ca/bc/gov/educ/api/institute/service/EventHandlerServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/institute/service/EventHandlerServiceTest.java index 9e9f2e91..f54058c1 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/institute/service/EventHandlerServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/institute/service/EventHandlerServiceTest.java @@ -246,35 +246,6 @@ public void testHandleEvent_givenEventTypeCREATE_SCHOOL_WITH_EXISTING_SCHOOL_NUM assertThat(schoolCreatedEvent.get().getEventStatus()).isEqualTo(MESSAGE_PUBLISHED.toString()); assertThat(schoolCreatedEvent.get().getEventOutcome()).isEqualTo(SCHOOL_CREATED.toString()); } - - @Test(expected = ConflictFoundException.class) - public void testHandleEvent_givenEventTypeCREATE_SCHOOL_WITH_CONFLICTING_SCHOOL_NUMBER__DoesExistAndSynchronousNatsMessage_shouldThrowError() throws IOException, ExecutionException, InterruptedException { - final DistrictTombstoneEntity dist = this.districtTombstoneRepository.save(this.createDistrictData()); - var existingSchoolEntity = this.createNewSchoolData("99000", "PUBLIC", "DISTONLINE"); - existingSchoolEntity.setDistrictEntity(dist); - schoolRepository.save(existingSchoolEntity); - - var schoolEntity = this.createNewSchoolData("99000", "PUBLIC", "DISTONLINE"); - - SchoolMapper map = SchoolMapper.mapper; - - School mappedSchool = map.toStructure(schoolEntity); - - mappedSchool.setDistrictId(dist.getDistrictId().toString()); - mappedSchool.setCreateDate(null); - mappedSchool.setUpdateDate(null); - mappedSchool.setGrades(List.of(createSchoolGrade())); - mappedSchool.setNeighborhoodLearning(List.of(createNeighborhoodLearning())); - mappedSchool.setAddresses(List.of(createSchoolAddress())); - - ObjectMapper objectMapper = new ObjectMapper(); - objectMapper.registerModule(new JavaTimeModule()).configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); - - var sagaId = UUID.randomUUID(); - final Event event = Event.builder().eventType(CREATE_SCHOOL).sagaId(sagaId).eventPayload(objectMapper.writeValueAsString(mappedSchool)).build(); - eventHandlerServiceUnderTest.handleCreateSchoolEvent(event); - } - @Test public void testHandleEvent_givenEventTypeUPDATE_SCHOOL__DoesExistAndSynchronousNatsMessage_shouldRespondWithData() throws IOException, ExecutionException, InterruptedException { final DistrictTombstoneEntity dist = this.districtTombstoneRepository.save(this.createDistrictData());