BDXR1IdentifierFactory implements IIdentifierFactory { @Nullable public BDXR1DocumentTypeIdentifier createDocumentTypeIdentifier (@Nullable final String sScheme, @Nullable final String sValue) { final String sRealScheme = nullNotEmpty (sScheme); final String sRealValue = nullNotEmpty (isDocumentTypeIdentifierCaseInsensitive (sRealScheme) ? getUnifiedValue (sValue) : sValue); if (isDocumentTypeIdentifierSchemeValid (sRealScheme) && isDocumentTypeIdentifierValueValid (sRealValue)) return new BDXR1DocumentTypeIdentifier (sRealScheme, sRealValue); return null; } BDXR1IdentifierFactory(); @Nonnull @Override String getDefaultDocumentTypeIdentifierScheme(); @Override boolean isDocumentTypeIdentifierCaseInsensitive(@Nullable final String sScheme); @Override boolean isDocumentTypeIdentifierSchemeValid(@Nullable final String sScheme); @Override boolean isDocumentTypeIdentifierValueValid(@Nullable final String sValue); @Nullable BDXR1DocumentTypeIdentifier createDocumentTypeIdentifier(@Nullable final String sScheme, @Nullable final String sValue); @Override boolean isParticipantIdentifierCaseInsensitive(@Nullable final String sScheme); @Override boolean isParticipantIdentifierSchemeValid(@Nullable final String sScheme); @Override boolean isParticipantIdentifierValueValid(@Nullable final String sValue); @Nullable BDXR1ParticipantIdentifier createParticipantIdentifier(@Nullable final String sScheme, @Nullable final String sValue); @Nonnull @Override String getDefaultProcessIdentifierScheme(); @Override boolean isProcessIdentifierCaseInsensitive(@Nullable final String sScheme); @Override boolean isProcessIdentifierValueValid(final String sValue); @Nullable BDXR1ProcessIdentifier createProcessIdentifier(@Nullable final String sScheme, @Nullable final String sValue); @Override String toString(); static final BDXR1IdentifierFactory INSTANCE; }
@Test public void testDocTypeIDCreation () { final BDXR1IdentifierFactory aIF = BDXR1IdentifierFactory.INSTANCE; assertNotNull (aIF.createDocumentTypeIdentifier (null, null)); assertNotNull (aIF.createDocumentTypeIdentifier (null, "any")); assertNotNull (aIF.createDocumentTypeIdentifier (null, "")); assertNotNull (aIF.createDocumentTypeIdentifier ("", "")); assertNull (aIF.createDocumentTypeIdentifier ("bla::#: }
@Test public void testDocTypeIDCaseInsensitive () { final BDXR1IdentifierFactory aIF = BDXR1IdentifierFactory.INSTANCE; final String sScheme = CBDXR1Identifier.DEFAULT_DOCUMENT_TYPE_IDENTIFIER_SCHEME; final IDocumentTypeIdentifier aID1 = aIF.createDocumentTypeIdentifier (sScheme, "abc"); assertEquals (sScheme, aID1.getScheme ()); assertEquals ("abc", aID1.getValue ()); final IDocumentTypeIdentifier aID2 = aIF.createDocumentTypeIdentifier (sScheme, "ABC"); assertEquals (sScheme, aID2.getScheme ()); assertEquals ("abc", aID2.getValue ()); assertTrue (aID1.hasSameContent (aID2)); }
@Test public void testDocTypeIDCaseSensitive () { final BDXR1IdentifierFactory aIF = BDXR1IdentifierFactory.INSTANCE; final String sScheme = "cs-doctype-scheme"; final IDocumentTypeIdentifier aID1 = aIF.createDocumentTypeIdentifier (sScheme, "abc"); assertEquals (sScheme, aID1.getScheme ()); assertEquals ("abc", aID1.getValue ()); final IDocumentTypeIdentifier aID2 = aIF.createDocumentTypeIdentifier (sScheme, "ABC"); assertEquals (sScheme, aID2.getScheme ()); assertEquals ("ABC", aID2.getValue ()); assertFalse (aID1.hasSameContent (aID2)); }