BDXR2IdentifierFactory implements IIdentifierFactory { @Nullable public BDXR2ProcessIdentifier createProcessIdentifier (@Nullable final String sScheme, @Nullable final String sValue) { final String sRealScheme = nullNotEmpty (sScheme); final String sRealValue = nullNotEmpty (isProcessIdentifierCaseInsensitive (sRealScheme) ? getUnifiedValue (sValue) : sValue); if (isProcessIdentifierSchemeValid (sRealScheme) && isProcessIdentifierValueValid (sRealValue)) return new BDXR2ProcessIdentifier (sRealScheme, sRealValue); return null; } BDXR2IdentifierFactory(); @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 BDXR2DocumentTypeIdentifier 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 BDXR2ParticipantIdentifier 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 BDXR2ProcessIdentifier createProcessIdentifier(@Nullable final String sScheme, @Nullable final String sValue); @Override String toString(); static final BDXR2IdentifierFactory INSTANCE; }
@Test public void testProcessIDCreation () { final BDXR2IdentifierFactory aIF = BDXR2IdentifierFactory.INSTANCE; assertNotNull (aIF.createProcessIdentifier (null, null)); assertNotNull (aIF.createProcessIdentifier (null, "any")); assertNotNull (aIF.createProcessIdentifier (null, "")); assertNotNull (aIF.createProcessIdentifier ("", "")); assertNotNull (aIF.createProcessIdentifier ("bla::#: }
@Test public void testProcessIDCaseInsensitive () { final BDXR2IdentifierFactory aIF = BDXR2IdentifierFactory.INSTANCE; final String sScheme = CBDXR2Identifier.DEFAULT_PROCESS_IDENTIFIER_SCHEME; final IProcessIdentifier aID1 = aIF.createProcessIdentifier (sScheme, "abc"); assertEquals (sScheme, aID1.getScheme ()); assertEquals ("abc", aID1.getValue ()); final IProcessIdentifier aID2 = aIF.createProcessIdentifier (sScheme, "ABC"); assertEquals (sScheme, aID2.getScheme ()); assertEquals ("abc", aID2.getValue ()); assertTrue (aID1.hasSameContent (aID2)); }
@Test public void testProcessIDCaseSensitive () { final BDXR2IdentifierFactory aIF = BDXR2IdentifierFactory.INSTANCE; final String sScheme = "cs-docid-qns"; final IProcessIdentifier aID1 = aIF.createProcessIdentifier (sScheme, "abc"); assertEquals (sScheme, aID1.getScheme ()); assertEquals ("abc", aID1.getValue ()); final IProcessIdentifier aID2 = aIF.createProcessIdentifier (sScheme, "ABC"); assertEquals (sScheme, aID2.getScheme ()); assertEquals ("ABC", aID2.getValue ()); assertFalse (aID1.hasSameContent (aID2)); }