Skip to content

Commit

Permalink
Removed invalid uts
Browse files Browse the repository at this point in the history
  • Loading branch information
SodhiA1 committed Nov 30, 2023
1 parent 1f09201 commit 6072f00
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 6072f00

Please sign in to comment.