@Test
@DisplayName("Should return HTTP code 200 when the data is correct")
@WithMockUser
public void scheduleConsultationScenery2() throws Exception{
var date = LocalDateTime.now().plusHours(2);
var specialty = Specialty.CARDIOLOGIA;
var consultationDetails = new ConsultationDataDetailsDTO(null, 2l, 5l, date);
when(consultationService.scheduleConsultation(any())).thenReturn(consultationDetails);
var response = mockMvc.perform(post("/consultation/schedule")
.contentType(MediaType.APPLICATION_JSON)
.content(jacksonTesterScheduleJson.write(
new ConsultationScheduleDataDTO(2l, 5l, date, specialty)
).getJson())
)
.andReturn().getResponse();
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
var expectedJson = jacksonTesterReturnJson.write(
consultationDetails
).getJson();
assertThat(response.getContentAsString()).isEqualTo(expectedJson);
}
Linha: when(consultationService.scheduleConsultation(any())).thenReturn(consultationDetails);
Erro:
Cannot resolve method 'thenReturn(ConsultationDataDetailsDTO)'
ConsultationDataDetailsDTO consultationDetails
= new ConsultationDataDetailsDTO(null, 2l, 5l, date)
java: no suitable method found for thenReturn(clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO)
method org.mockito.stubbing.OngoingStubbing.thenReturn(org.springframework.http.ResponseEntity<clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO>) is not applicable
(argument mismatch; clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO cannot be converted to org.springframework.http.ResponseEntity<clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO>)
method org.mockito.stubbing.OngoingStubbing.thenReturn(org.springframework.http.ResponseEntity<clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO>,org.springframework.http.ResponseEntity<clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO>...) is not applicable
(argument mismatch; clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO cannot be converted to org.springframework.http.ResponseEntity<clin.dan.api.Features.Consultation.ConsultationDTOs.ConsultationDataDetailsDTO>)