use of uk.nhs.adaptors.connector.model.MigrationStatusLog in project nia-patient-switching-standard-adaptor by NHSDigital.
the class PatientTransferServiceTest method handlePatientMigrationRequestWhenRequestIsNew.
@Test
public void handlePatientMigrationRequestWhenRequestIsNew() {
var expectedPssQueueMessage = TransferRequestMessage.builder().conversationId(CONVERSATION_ID).patientNhsNumber(PATIENT_NHS_NUMBER).toAsid(HEADERS.get(TO_ASID)).fromAsid(HEADERS.get(FROM_ASID)).toOds(HEADERS.get(TO_ODS)).fromOds(HEADERS.get(FROM_ODS)).build();
var migrationRequestId = 1;
OffsetDateTime now = OffsetDateTime.now();
when(dateUtils.getCurrentOffsetDateTime()).thenReturn(now);
when(patientMigrationRequestDao.getMigrationRequest(CONVERSATION_ID)).thenReturn(null);
when(patientMigrationRequestDao.getMigrationRequestId(CONVERSATION_ID)).thenReturn(migrationRequestId);
when(mdcService.getConversationId()).thenReturn(CONVERSATION_ID);
MigrationStatusLog patientMigrationRequest = service.handlePatientMigrationRequest(parameters, HEADERS);
assertThat(patientMigrationRequest).isEqualTo(null);
verify(pssQueuePublisher).sendToPssQueue(expectedPssQueueMessage);
verify(patientMigrationRequestDao).addNewRequest(PATIENT_NHS_NUMBER, CONVERSATION_ID, LOSING_ODS_CODE, WINNING_ODS_CODE);
verify(migrationStatusLogDao).addMigrationStatusLog(MigrationStatus.REQUEST_RECEIVED, now, migrationRequestId);
}
Aggregations