Skip to content

Commit

Permalink
Small fixes for pulling back sessions.
Browse files Browse the repository at this point in the history
  • Loading branch information
arcshiftsolutions committed Oct 22, 2024
1 parent 3911e9d commit 4e59d58
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
import ca.bc.gov.educ.eas.api.mappers.UUIDMapper;
import ca.bc.gov.educ.eas.api.model.v1.SessionEntity;
import ca.bc.gov.educ.eas.api.struct.v1.Session;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValuePropertyMappingStrategy;
import org.mapstruct.factory.Mappers;

@Mapper(uses = {UUIDMapper.class, LocalDateTimeMapper.class, AssessmentMapper.class})
Expand All @@ -17,7 +14,6 @@ public interface SessionMapper {

Session toStructure(SessionEntity entity);

@BeanMapping(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
SessionEntity toEntity(Session session);

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
* The type Base address.
*/
@EqualsAndHashCode(callSuper=false)
@Data
public abstract class BaseAddress extends BaseRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.springframework.data.annotation.ReadOnlyProperty;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
* DTO for Session entity.
Expand All @@ -36,8 +36,10 @@ public class Session extends BaseRequest implements Serializable {
private Integer courseYear;

@NotNull(message = "activeFromDate cannot be null")
private LocalDateTime activeFromDate;
private String activeFromDate;

@NotNull(message = "activeUntilDate cannot be null")
private LocalDateTime activeUntilDate;
private String activeUntilDate;

private List<Assessment> assessments;
}
4 changes: 2 additions & 2 deletions api/src/test/java/ca/bc/gov/educ/eas/api/BaseEasAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public Session createMockSession() {
.schoolYear(String.valueOf(currentDate.getYear()))
.courseYear(currentDate.getYear())
.courseMonth(currentDate.getMonthValue())
.activeFromDate(currentDate.minusMonths(2))
.activeUntilDate(currentDate.plusMonths(2))
.activeFromDate(currentDate.minusMonths(2).toString())
.activeUntilDate(currentDate.plusMonths(2).toString())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ void testSessionManagement_GetAllSessions_ShouldReturnOK() throws Exception {
void testSessionManagement_UpdateSession_ShouldReturnOK() throws Exception {
SessionEntity sessionEntity = sessionRepository.save(createMockSessionEntity());
Session updatedSession = new Session();
updatedSession.setActiveFromDate(LocalDateTime.now().plusDays(20));
updatedSession.setActiveUntilDate(LocalDateTime.now().plusDays(120));
updatedSession.setActiveFromDate(LocalDateTime.now().plusDays(20).toString());
updatedSession.setActiveUntilDate(LocalDateTime.now().plusDays(120).toString());
updatedSession.setUpdateUser("test");
this.mockMvc.perform(put(URL.SESSIONS_URL + "/" + sessionEntity.getSessionID())
.with(jwt().jwt(jwt -> jwt.claim("scope", "WRITE_EAS_SESSIONS")))
Expand All @@ -103,15 +103,15 @@ void testSessionManagement_UpdateSession_ShouldReturnOK() throws Exception {

var updatedSessionEntity = sessionRepository.findById(sessionEntity.getSessionID());
assertThat(updatedSessionEntity).isPresent();
assertThat(updatedSessionEntity.get().getActiveFromDate().toLocalDate()).isEqualTo(updatedSession.getActiveFromDate().toLocalDate());
assertThat(updatedSessionEntity.get().getActiveUntilDate().toLocalDate()).isEqualTo(updatedSession.getActiveUntilDate().toLocalDate());
assertThat(updatedSessionEntity.get().getActiveFromDate().toString().substring(0,25)).isEqualTo(updatedSession.getActiveFromDate().substring(0,25));
assertThat(updatedSessionEntity.get().getActiveUntilDate().toString().substring(0,25)).isEqualTo(updatedSession.getActiveUntilDate().substring(0,25));
}

@Test
void testSessionManagement_UpdateSession_ShouldReturNotFound() throws Exception {
Session updatedSession = new Session();
updatedSession.setActiveFromDate(LocalDateTime.now().plusDays(20));
updatedSession.setActiveUntilDate(LocalDateTime.now().plusDays(120));
updatedSession.setActiveFromDate(LocalDateTime.now().plusDays(20).toString());
updatedSession.setActiveUntilDate(LocalDateTime.now().plusDays(120).toString());
updatedSession.setUpdateUser("test");
this.mockMvc.perform(put(URL.SESSIONS_URL + "/" + UUID.randomUUID())
.with(jwt().jwt(jwt -> jwt.claim("scope", "WRITE_EAS_SESSIONS")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void tearDown() {
}

@Test
void testHandleEvent_givenEventTypeGET_STUDENT__whenNoStudentExist_shouldHaveEventOutcomeSTUDENT_NOT_FOUND() throws IOException {
void testHandleEvent_givenEventTypeGET_OPEN_ASSESSMENT_SESSIONS__whenNoStudentExist_shouldHaveEventOutcomeSESSIONS_FOUND() throws IOException {
var sagaId = UUID.randomUUID();
final Event event = Event.builder().eventType(EventType.GET_OPEN_ASSESSMENT_SESSIONS).sagaId(sagaId).replyTo(EAS_API_TOPIC).eventPayload(UUID.randomUUID().toString()).build();
byte[] response = eventHandlerServiceUnderTest.handleGetOpenAssessmentSessionsEvent(event, isSynchronous);
Expand Down

0 comments on commit 4e59d58

Please sign in to comment.