Source:
public void shouldGetAllIdentifierSourcesBasedOnPrimaryIdentifierType() { when(Context.getService(IdentifierSourceService.class)).thenReturn(identifierSourceService); when(Context.getAdministrationService()).thenReturn(administrationService); when(administrationService.getGlobalProperty("bahmni.primaryIdentifierType")).thenReturn("dead-cafe"); when(Context.getPatientService()).thenReturn(patientService); PatientIdentifierType patientIdentifierType = new PatientIdentifierType(1); patientIdentifierType.setName("abcd"); PatientIdentifierType patientIdentifierType2 = new PatientIdentifierType(1); patientIdentifierType2.setName("abcd"); when(patientService.getPatientIdentifierTypeByUuid("dead-cafe")).thenReturn(patientIdentifierType2); Map<PatientIdentifierType, List<IdentifierSource>> identifierSourcesByType = new HashMap<PatientIdentifierType, List<IdentifierSource>>(); List<IdentifierSource> identifierSources = new ArrayList<IdentifierSource>(); SequentialIdentifierGenerator sequentialIdentifierGenerator = new SequentialIdentifierGenerator(); sequentialIdentifierGenerator.setName("GAN"); sequentialIdentifierGenerator.setUuid("alive-cafe"); sequentialIdentifierGenerator.setPrefix("GAN"); identifierSources.add(sequentialIdentifierGenerator); identifierSourcesByType.put(patientIdentifierType, identifierSources); List<IdentifierSource> identifierSources2 = new ArrayList<IdentifierSource>(); SequentialIdentifierGenerator sequentialIdentifierGenerator2 = new SequentialIdentifierGenerator(); sequentialIdentifierGenerator2.setName("OMRS"); sequentialIdentifierGenerator2.setUuid("dead-cafe"); sequentialIdentifierGenerator2.setPrefix("OMRS"); identifierSources2.add(sequentialIdentifierGenerator2); identifierSourcesByType.put(patientIdentifierType2, identifierSources2); when(identifierSourceService.getIdentifierSourcesByType(false)).thenReturn(identifierSourcesByType); List<org.openmrs.module.idgen.contract.IdentifierSource> allIdentifierSources = identifierSourceServiceWrapperImpl.getAllIdentifierSourcesOfPrimaryIdentifierType(); assertEquals(allIdentifierSources.size(), 1); assertEquals("OMRS",(allIdentifierSources.get(0).getName())); assertEquals("dead-cafe",(allIdentifierSources.get(0).getUuid())); assertEquals("OMRS",(allIdentifierSources.get(0).getPrefix())); }

Target:
public void shouldGetAllIdentifierSourcesBasedOnPrimaryIdentifierType() { when(Context.getService(IdentifierSourceService.class)).thenReturn(identifierSourceService); when(Context.getAdministrationService()).thenReturn(administrationService); when(administrationService.getGlobalProperty("openmrs.primaryIdentifierType")).thenReturn("dead-cafe"); when(Context.getPatientService()).thenReturn(patientService); PatientIdentifierType patientIdentifierType = new PatientIdentifierType(1); patientIdentifierType.setName("abcd"); PatientIdentifierType patientIdentifierType2 = new PatientIdentifierType(1); patientIdentifierType2.setName("abcd"); when(patientService.getPatientIdentifierTypeByUuid("dead-cafe")).thenReturn(patientIdentifierType2); Map<PatientIdentifierType, List<IdentifierSource>> identifierSourcesByType = new HashMap<PatientIdentifierType, List<IdentifierSource>>(); List<IdentifierSource> identifierSources = new ArrayList<IdentifierSource>(); SequentialIdentifierGenerator sequentialIdentifierGenerator = new SequentialIdentifierGenerator(); sequentialIdentifierGenerator.setName("GAN"); sequentialIdentifierGenerator.setUuid("alive-cafe"); sequentialIdentifierGenerator.setPrefix("GAN"); identifierSources.add(sequentialIdentifierGenerator); identifierSourcesByType.put(patientIdentifierType, identifierSources); List<IdentifierSource> identifierSources2 = new ArrayList<IdentifierSource>(); SequentialIdentifierGenerator sequentialIdentifierGenerator2 = new SequentialIdentifierGenerator(); sequentialIdentifierGenerator2.setName("OMRS"); sequentialIdentifierGenerator2.setUuid("dead-cafe"); sequentialIdentifierGenerator2.setPrefix("OMRS"); identifierSources2.add(sequentialIdentifierGenerator2); identifierSourcesByType.put(patientIdentifierType2, identifierSources2); when(identifierSourceService.getIdentifierSourcesByType(false)).thenReturn(identifierSourcesByType); List<org.openmrs.module.idgen.contract.IdentifierSource> allIdentifierSources = identifierSourceServiceWrapperImpl.getAllIdentifierSourcesOfPrimaryIdentifierType(); assertEquals(allIdentifierSources.size(), 1); assertEquals("OMRS",(allIdentifierSources.get(0).getName())); assertEquals("dead-cafe",(allIdentifierSources.get(0).getUuid())); assertEquals("OMRS",(allIdentifierSources.get(0).getPrefix())); }