@Test
public void testFindAllPatientLegalRepresentativeAssociationDtos() {

	Patient patient = mock(Patient.class);
	when(patientRepository.findByUsername(anyString())).thenReturn(patient);
	when(patient.getId()).thenReturn((long) 1);
	List<PatientLegalRepresentativeAssociation> allAssociations = new ArrayList<PatientLegalRepresentativeAssociation>();
	List<PatientLegalRepresentativeAssociationDto> associationDtos = new ArrayList<PatientLegalRepresentativeAssociationDto>();
	List<PatientLegalRepresentativeAssociationDto> associationDtosSpy = spy(associationDtos);
	PatientLegalRepresentativeAssociation association = mock(PatientLegalRepresentativeAssociation.class);
	allAssociations.add(association);
	PatientLegalRepresentativeAssociationPk associationPk = mock(PatientLegalRepresentativeAssociationPk.class);
	Patient patient2 = mock(Patient.class);
	PatientLegalRepresentativeAssociationDto associationDto = mock(PatientLegalRepresentativeAssociationDto.class);
	Patient legalRep = mock(Patient.class);
	when(patientLegalRepresentativeAssociationRepository.findAll())
			.thenReturn(allAssociations);
	when(association.getPatientLegalRepresentativeAssociationPk())
			.thenReturn(associationPk);
	when(associationPk.getPatient()).thenReturn(patient2);
	when(associationPk.getLegalRepresentative()).thenReturn(legalRep);
	when(patient2.getId()).thenReturn((long) 1);
	when(
			modelMapper.map(association,
					PatientLegalRepresentativeAssociationDto.class))
			.thenReturn(associationDto);
	associationDtos = patientLegalRepresentativeAssociationService
			.findAllPatientLegalRepresentativeAssociationDtos();
	assertEquals(associationDto, associationDtos.get(0));
}