### Question:
Dstu3HumanNameFhirToDhisTransformerUtils extends AbstractHumanNameFhirToDhisTransformerUtils { @Override @Nullable public HumanName getPrimaryName( @Nonnull List<? extends ICompositeType> names ) { return getOptionalPrimaryName( names ).orElse( new HumanName() ); } Dstu3HumanNameFhirToDhisTransformerUtils( @Nonnull ScriptExecutionContext scriptExecutionContext, @Nonnull Dstu3DateTimeFhirToDhisTransformerUtils dateTimeTransformerUtils ); @Nonnull @Override Set<FhirVersion> getFhirVersions(); @Override @Nullable String getSingleGiven( @Nullable ICompositeType humanName ); @Override @Nullable String getFirstGiven( @Nullable ICompositeType humanName ); @Nullable @Override String getSecondGiven( @Nullable ICompositeType humanName ); @Override @Nullable HumanName getPrimaryName( @Nonnull List<? extends ICompositeType> names );  }### Answer:
@Test public void primaryMaiden() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.MAIDEN ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.OLD ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryTemp() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.TEMP ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.MAIDEN ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryNickname() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.NICKNAME ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.TEMP ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryAnonymous() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.ANONYMOUS ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.NICKNAME ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryUsual() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.USUAL ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.ANONYMOUS ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryNull() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.NULL ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.ANONYMOUS ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryOther() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName() ); humanNames.add( new HumanName().setUse( HumanName.NameUse.ANONYMOUS ) ); Assert.assertEquals( humanNames.get( 0 ), utils.getPrimaryName( humanNames ) ); }
@Test public void primaryNothing() { final List<HumanName> humanNames = new ArrayList<>(); Assert.assertNotNull( utils.getPrimaryName( humanNames ) ); }
@Test public void primaryExpired() { final List<HumanName> humanNames = new ArrayList<>(); humanNames.add( new HumanName().setUse( HumanName.NameUse.OFFICIAL ) .setPeriod( new Period().setEnd( Date.from( ZonedDateTime.now().minusDays( 1 ).toInstant() ) ) ) ); humanNames.add( new HumanName().setUse( HumanName.NameUse.OLD ) ); Assert.assertEquals( humanNames.get( 1 ), utils.getPrimaryName( humanNames ) ); }