Skip to content

Commit

Permalink
new test and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Jan 17, 2025
1 parent 0d75b88 commit 746b2b4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ Note:

- If you configure ``base-url``, it should include a "/" after the hostname like this: ``https://demo.dataverse.org/``.
- When using multiple PermaLink providers, you should avoid ambiguous authority/separator/shoulder combinations that would result in the same overall prefix.
- Configuring PermaLink providers differing only by their separator values is not supported.
- In general, PermaLink authority/shoulder values should be alphanumeric. For other cases, admins may need to consider the potential impact of special characters in S3 storage identifiers, resolver URLs, exports, etc.

.. _dataverse.pid.*.handlenet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;


@ExtendWith(MockitoExtension.class)
Expand All @@ -64,7 +65,7 @@
@JvmSetting(key = JvmSettings.PID_PROVIDER_LABEL, value = "perma 2", varArgs = "perma2")
@JvmSetting(key = JvmSettings.PID_PROVIDER_TYPE, value = PermaLinkPidProvider.TYPE, varArgs = "perma2")
@JvmSetting(key = JvmSettings.PID_PROVIDER_AUTHORITY, value = "DANSLINK", varArgs = "perma2")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "QE", varArgs = "perma2")
@JvmSetting(key = JvmSettings.PID_PROVIDER_SHOULDER, value = "QQ", varArgs = "perma2")
@JvmSetting(key = JvmSettings.PID_PROVIDER_MANAGED_LIST, value = "perma:LINKIT/FK2ABCDEF", varArgs ="perma2")
@JvmSetting(key = JvmSettings.PERMALINK_SEPARATOR, value = "/", varArgs = "perma2")
@JvmSetting(key = JvmSettings.PERMALINK_BASE_URL, value = "https://example.org/123/citation?persistentId=perma:", varArgs = "perma2")
Expand Down Expand Up @@ -133,6 +134,8 @@ public class PidUtilTest {

@Mock
private SettingsServiceBean settingsServiceBean;

static PidProviderFactoryBean pidService;

@BeforeAll
//FWIW @JvmSetting doesn't appear to work with @BeforeAll
Expand Down Expand Up @@ -228,14 +231,28 @@ public void testPermaLinkParsing() throws IOException {
assertEquals("perma1", pid3.getProviderId());

//Repeat the basics with a permalink associated with perma2
String pid4String = "perma:DANSLINK/QE-5A-XN55";
String pid4String = "perma:DANSLINK/QQ-5A-XN55";
GlobalId pid5 = PidUtil.parseAsGlobalID(pid4String);
assertEquals("perma2", pid5.getProviderId());
assertEquals(pid4String, pid5.asString());
assertEquals("https://example.org/123/citation?persistentId=" + pid4String, pid5.asURL());

}

@Test
public void testPermaLinkGenerationiWithSeparator() throws IOException {
Dataset ds = new Dataset();
pidService = Mockito.mock(PidProviderFactoryBean.class);
Mockito.when(pidService.isGlobalIdLocallyUnique(any(GlobalId.class))).thenReturn(true);
PidProvider p = PidUtil.getPidProvider("perma1");
p.setPidProviderServiceBean(pidService);
p.generatePid(ds);
System.out.println("DS sep " + ds.getSeparator());
System.out.println("Generated perma identifier" + ds.getGlobalId().asString());
System.out.println("Provider prefix for perma identifier" + p.getAuthority() + p.getSeparator() + p.getShoulder());
assertTrue(ds.getGlobalId().asRawIdentifier().startsWith(p.getAuthority() + p.getSeparator() + p.getShoulder()));
}

@Test
public void testDOIParsing() throws IOException {

Expand Down

0 comments on commit 746b2b4

Please sign in to comment.