### Question:
FhirToDhisTransformerContextImpl implements FhirToDhisTransformerContext { @Nullable @Override public String extractDhisId( @Nullable Object idElement ) { if ( idElement == null ) { return null; } final String id; if ( idElement instanceof IIdType ) { final IIdType idType = (IIdType) idElement; if ( idType.isLocal() ) { return null; } id = idType.getIdPart(); } else { id = idElement.toString(); } if ( id == null ) { return null; } if ( DhisResourceId.isValidId( id ) ) { return id; } try { return DhisFhirResourceId.parse( id ).getId(); } catch ( IllegalArgumentException e ) { throw new TransformerDataException( "Not a valid DHIS2 FHIR ID: " + id, e ); } } FhirToDhisTransformerContextImpl( @Nonnull FhirRequest fhirRequest, boolean creationDisabled ); @Nonnull @Override FhirRequest getFhirRequest(); @Nullable @Override Reference createReference( @Nullable String value, @Nonnull Object referenceType ); @Nullable @Override String extractDhisId( @Nullable Object idElement ); @Nonnull @Override ZonedDateTime now(); @Override boolean isCreationDisabled(); @Override void fail( @Nonnull String message ); @Nullable @Override String getDhisUsername(); @Nonnull @Override FhirVersion getFhirVersion(); @Override void setAttribute( @Nonnull String name, @Nullable Object value ); @Nullable @Override Object getAttribute( @Nonnull String name );  }### Answer:
@Test public void extractDhisIdNull() { Assert.assertNull( context.extractDhisId( null ) ); }
@Test public void extractDhisIdSimple() { Assert.assertEquals( "983jsh283jsa", context.extractDhisId( "983jsh283jsa" ) ); }
@Test public void extractDhisIdComplex() { Assert.assertEquals( "LMYkcW3hE5b", context.extractDhisId( "LMYkcW3hE5b" ) ); }
@Test public void extractDhisIdLocale() { Assert.assertNull( context.extractDhisId( new IdDt( "#1" ) ) ); }
@Test public void extractDhisIdType() { Assert.assertEquals( "LMYkcW3hE5b", context.extractDhisId( new IdDt( "Patient/LMYkcW3hE5b" ) ) ); }
@Test( expected = TransformerDataException.class ) public void extractDhisIdTypeInvalid() { context.extractDhisId( new IdDt( "Patient/-LMYkcW3hE5b-5f9ebdc9852e4c8387ca795946aabc35" ) ); }