// Update Path (when id is not null) @Test public void testMap() { ProcedureObservationDto dto = mock(ProcedureObservationDto.class); ProcedureObservation procedure = mock(ProcedureObservation.class); when(dto.getId()).thenReturn(1L); when(dto.getPatientId()).thenReturn(1L); when(dto.getProcedureTypeCode()).thenReturn("1"); when(dto.getProcedureTypeName()).thenReturn("typeName1"); when(dto.getProcedureStatusCode()).thenReturn("1"); when(procedureObservationRepository.findOne(dto.getId())).thenReturn(procedure); ProcedureObservation actual = sut.map(dto); assertEquals(procedure, actual); }
// Create Path (when id is null) @Test public void testMapUnlucky() { ProcedureObservationDto dto = mock(ProcedureObservationDto.class); Patient patient = mock(Patient.class); when(patient.getId()).thenReturn(1L); when(dto.getPatientId()).thenReturn(1L); when(dto.getProcedureTypeCode()).thenReturn("1"); when(dto.getProcedureTypeName()).thenReturn("typeName1"); when(dto.getProcedureStatusCode()).thenReturn("1"); when(dto.getBodySiteCode()).thenReturn("1"); when(dto.getId()).thenReturn(null); when(patientRepository.findOne(dto.getPatientId())).thenReturn(patient); ProcedureObservation actual = sut.map(dto); Assert.assertNotNull(actual); assertEquals(dto.getPatientId(), actual.getPatient().getId()); }