DOIIdentifierProvider extends IdentifierProvider { @Override public boolean supports(Class<? extends Identifier> identifier) { return DOI.class.isAssignableFrom(identifier); } protected  DOIIdentifierProvider(); @Required void setDOIConnector(DOIConnector connector); @Override boolean supports(Class<? extends Identifier> identifier); @Override boolean supports(String identifier); @Override String register(Context context, DSpaceObject dso); @Override void register(Context context, DSpaceObject dso, String identifier); @Override void reserve(Context context, DSpaceObject dso, String identifier); void reserveOnline(Context context, DSpaceObject dso, String identifier); void registerOnline(Context context, DSpaceObject dso, String identifier); void updateMetadata(Context context, DSpaceObject dso, String identifier); void updateMetadataOnline(Context context, DSpaceObject dso, String identifier); @Override String mint(Context context, DSpaceObject dso); @Override DSpaceObject resolve(Context context, String identifier, String... attributes); @Override String lookup(Context context, DSpaceObject dso); @Override void delete(Context context, DSpaceObject dso); @Override void delete(Context context, DSpaceObject dso, String identifier); void deleteOnline(Context context, String identifier); DSpaceObject getObjectByDOI(Context context, String identifier); String getDOIByObject(Context context, DSpaceObject dso); String getDOIOutOfObject(DSpaceObject dso); static final String MD_SCHEMA; static final String DOI_ELEMENT; static final String DOI_QUALIFIER; static final Integer TO_BE_REGISTERED; static final Integer TO_BE_RESERVED; static final Integer IS_REGISTERED; static final Integer IS_RESERVED; static final Integer UPDATE_RESERVED; static final Integer UPDATE_REGISTERED; static final Integer UPDATE_BEFORE_REGISTRATION; static final Integer TO_BE_DELETED; static final Integer DELETED; }
@Test public void testSupports_Class() { Class<? extends Identifier> identifier = DOI.class; assertTrue("DOI should be supported", provider.supports(identifier)); }
@Test public void testSupports_valid_String() { String[] validDOIs = new String[] { "10.5072/123abc-lkj/kljl", PREFIX + "/" + NAMESPACE_SEPARATOR + "lkjljasd1234", DOI.SCHEME + "10.5072/123abc-lkj/kljl", "http: DOI.RESOLVER + "/10.5072/123abc-lkj/kljl" }; for (String doi : validDOIs) { assertTrue("DOI should be supported", provider.supports(doi)); } }
@Test public void testDoes_not_support_invalid_String() { String[] invalidDOIs = new String[] { "11.5072/123abc-lkj/kljl", "http: "", null }; for (String notADoi : invalidDOIs) { assertFalse("Invalid DOIs shouldn't be supported", provider.supports(notADoi)); } }