From c819088b0f8bc2e49697879aa20a5fe94607f472 Mon Sep 17 00:00:00 2001 From: Torsten Krohn Date: Wed, 27 Jul 2022 10:26:00 +0200 Subject: [PATCH] fix: missing lastMessageType response due to changed alias-message definition --- api/userservice.yaml | 5 ++ .../UserControllerSessionE2EIT.java | 66 ++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/api/userservice.yaml b/api/userservice.yaml index f87ecb419..26779af5d 100644 --- a/api/userservice.yaml +++ b/api/userservice.yaml @@ -2090,6 +2090,8 @@ components: $ref: '#/components/schemas/VideoCallMessageDTO' messageType: $ref: '#/components/schemas/MessageType' + content: + type: string ForwardMessageDTO: type: object @@ -2143,6 +2145,9 @@ components: MessageType: type: string enum: + - "APPOINTMENT_SET" + - "APPOINTMENT_CANCELLED" + - "APPOINTMENT_RESCHEDULED" - "FURTHER_STEPS" - "UPDATE_SESSION_DATA" - "FORWARD" diff --git a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java index 55e2576ea..ef0fc6598 100644 --- a/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java +++ b/src/test/java/de/caritas/cob/userservice/api/adapters/web/controller/UserControllerSessionE2EIT.java @@ -505,6 +505,66 @@ void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeE2eeActiv .andExpect(jsonPath("sessions[1].chat", is(nullValue()))); } + @Test + @WithMockUser(authorities = AuthorityValue.USER_DEFAULT) + void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeResetLastMessage() + throws Exception { + givenAValidUser(true); + givenAValidConsultant(); + givenASessionInProgress(); + givenAValidRocketChatSystemUser(); + givenAValidRocketChatGetRoomsResponse(session.getGroupId(), + MessageType.REASSIGN_CONSULTANT_RESET_LAST_MESSAGE, null); + givenAnEmptyRocketChatGetSubscriptionsResponse(); + user.getSessions().forEach(session -> + givenAValidRocketChatInfoUserResponse(session.getConsultant()) + ); + + mockMvc.perform( + get("/users/sessions/askers") + .cookie(CSRF_COOKIE) + .header(CSRF_HEADER, CSRF_VALUE) + .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("sessions", hasSize(2))) + .andExpect(jsonPath("sessions[*].session.lastMessageType", + containsInAnyOrder("REASSIGN_CONSULTANT_RESET_LAST_MESSAGE", "FURTHER_STEPS"))) + .andExpect(jsonPath("sessions[0].chat", is(nullValue()))) + .andExpect(jsonPath("sessions[1].chat", is(nullValue()))); + } + + @Test + @WithMockUser(authorities = AuthorityValue.USER_DEFAULT) + void getSessionsForAuthenticatedUserShouldReturnSessionsLastMessageTypeReassignConsultant() + throws Exception { + givenAValidUser(true); + givenAValidConsultant(); + givenASessionInProgress(); + givenAValidRocketChatSystemUser(); + givenAValidRocketChatGetRoomsResponse(session.getGroupId(), MessageType.REASSIGN_CONSULTANT, + "a message"); + givenAnEmptyRocketChatGetSubscriptionsResponse(); + user.getSessions().forEach(session -> + givenAValidRocketChatInfoUserResponse(session.getConsultant()) + ); + + mockMvc.perform( + get("/users/sessions/askers") + .cookie(CSRF_COOKIE) + .header(CSRF_HEADER, CSRF_VALUE) + .header(RC_TOKEN_HEADER_PARAMETER_NAME, RC_TOKEN) + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("sessions", hasSize(2))) + .andExpect(jsonPath("sessions[*].session.lastMessageType", + containsInAnyOrder("REASSIGN_CONSULTANT", "FURTHER_STEPS"))) + .andExpect(jsonPath("sessions[0].chat", is(nullValue()))) + .andExpect(jsonPath("sessions[1].chat", is(nullValue()))); + } + @Test @WithMockUser(authorities = {AuthorityValue.USER_DEFAULT}) void getSessionsForGroupOrFeedbackGroupIdsShouldFindSessionsByGroupOrFeedbackGroup() @@ -599,7 +659,8 @@ void getSessionsForGroupOrFeedbackGroupIdsShouldContainConsultantOfUserSession() .andExpect(status().isOk()) .andExpect(jsonPath("sessions[0].session.groupId", is("YWKxhFX5K2HPpsFbs"))) .andExpect(jsonPath("sessions[0].consultant.username", is("u25main"))) - .andExpect(jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc"))) + .andExpect( + jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc"))) .andExpect(jsonPath("sessions[0].consultant.firstName").doesNotExist()) .andExpect(jsonPath("sessions[0].consultant.lastName").doesNotExist()) .andExpect(jsonPath("sessions[0].agency", is(notNullValue()))) @@ -717,7 +778,8 @@ void getSessionForIdShouldFindSessionsBySessionId() .andExpect(jsonPath("sessions[0].session.id", is(900))) .andExpect(jsonPath("sessions[0].session.groupId", is("YWKxhFX5K2HPpsFbs"))) .andExpect(jsonPath("sessions[0].consultant.username", is("u25main"))) - .andExpect(jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc"))) + .andExpect( + jsonPath("sessions[0].consultant.id", is("bad14912-cf9f-4c16-9d0e-fe8ede9b60dc"))) .andExpect(jsonPath("sessions[0].consultant.firstName").doesNotExist()) .andExpect(jsonPath("sessions[0].consultant.lastName").doesNotExist()) .andExpect(jsonPath("sessions[0].agency", is(notNullValue())))