Search in sources :

Example 31 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class IdentifierTypeConverterTest method testToPojo.

@Test
public void testToPojo() {
    IdentifierTypeEntity entity1 = new IdentifierTypeEntity();
    entity1.setId(1l);
    entity1.setName("NAME_TEST");
    entity1.setIsDeprecated(true);
    entity1.setResolutionPrefix("prefix");
    entity1.setValidationRegex("validation");
    entity1.setDateCreated(new Date(10, 10, 10));
    entity1.setLastModified(new Date(11, 11, 11));
    ClientDetailsEntity client = new ClientDetailsEntity();
    client.setClientName("clientName");
    entity1.setSourceClient(client);
    IdentifierType id = new IdentifierTypePOJOConverter().fromEntity(entity1);
    assertEquals(Long.valueOf(1l), id.getPutCode());
    assertEquals("name-test", id.getName());
    assertEquals(true, id.getDeprecated());
    assertEquals("prefix", id.getResolutionPrefix());
    assertEquals("validation", id.getValidationRegex());
    assertEquals(new Date(10, 10, 10), id.getDateCreated());
    assertEquals(new Date(11, 11, 11), id.getLastModified());
    assertEquals("clientName", id.getSourceClient().getClientName());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) IdentifierTypeEntity(org.orcid.persistence.jpa.entities.IdentifierTypeEntity) IdentifierTypePOJOConverter(org.orcid.core.adapter.impl.IdentifierTypePOJOConverter) IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date) BaseTest(org.orcid.core.BaseTest) Test(org.junit.Test)

Example 32 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class OrcidClientGroupManagerTest method testCreateOrcidCreatorClientGroup.

@Test
public void testCreateOrcidCreatorClientGroup() {
    OrcidClientGroup createdGroup = orcidClientGroupManager.createOrUpdateOrcidClientGroup(group);
    assertNotNull(createdGroup);
    assertEquals(group.getGroupName(), createdGroup.getGroupName());
    assertEquals(group.getEmail(), createdGroup.getEmail());
    assertNotNull(createdGroup.getGroupOrcid());
    List<OrcidClient> createdClients = createdGroup.getOrcidClient();
    assertNotNull(createdClients);
    assertEquals(2, createdClients.size());
    Map<String, OrcidClient> createdClientsMappedByName = new HashMap<String, OrcidClient>();
    for (OrcidClient createdClient : createdClients) {
        assertNotNull(createdClient.getClientId());
        assertNotNull(createdClient.getClientSecret());
        assertNotNull(createdClient.getIdp());
        createdClientsMappedByName.put(createdClient.getDisplayName(), createdClient);
    }
    OrcidClient complexityClient = createdClientsMappedByName.get("Ecological Complexity");
    assertNotNull(complexityClient);
    assertEquals("http://www.journals.elsevier.com/ecological-complexity", complexityClient.getWebsite());
    assertEquals("An International Journal on Biocomplexity in the Environment and Theoretical Ecology", complexityClient.getShortDescription());
    List<RedirectUri> createdRedirectUris = complexityClient.getRedirectUris().getRedirectUri();
    assertNotNull(createdRedirectUris);
    assertEquals(1, createdRedirectUris.size());
    assertEquals("http://www.journals.elsevier.com/ecological-complexity/orcid-callback", createdRedirectUris.get(0).getValue());
    // Look up client details directly to check scopes
    ClientDetailsEntity complexityEntity = clientDetailsManager.findByClientId(complexityClient.getClientId());
    Set<String> clientScopeTypes = complexityEntity.getScope();
    assertNotNull(clientScopeTypes);
    assertTrue(clientScopeTypes.contains("/orcid-profile/read-limited"));
    assertTrue(clientScopeTypes.contains("/orcid-bio/read-limited"));
    assertTrue(clientScopeTypes.contains("/orcid-works/read-limited"));
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) OrcidClientGroup(org.orcid.jaxb.model.clientgroup.OrcidClientGroup) HashMap(java.util.HashMap) OrcidClient(org.orcid.jaxb.model.clientgroup.OrcidClient) RedirectUri(org.orcid.jaxb.model.clientgroup.RedirectUri) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 33 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class NotificationManagerTest method testAdminDelegateRequest.

@Test
public void testAdminDelegateRequest() throws JAXBException, IOException, URISyntaxException {
    SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
    when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
    when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
    for (Locale locale : Locale.values()) {
        notificationManager.sendDelegationRequestEmail("0000-0000-0000-0003", "0000-0000-0000-0003", "http://test.orcid.org");
    }
}
Also used : Locale(org.orcid.jaxb.model.message.Locale) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 34 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class ExternalIdentifierManagerTest method testAddExternalIdentifierToUnclaimedRecordPreserveExternalIdentifierVisibility.

@Test
public void testAddExternalIdentifierToUnclaimedRecordPreserveExternalIdentifierVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PersonExternalIdentifier extId = getExternalIdentifier();
    extId = externalIdentifierManager.createExternalIdentifier(unclaimedOrcid, extId, true);
    extId = externalIdentifierManager.getExternalIdentifier(unclaimedOrcid, extId.getPutCode());
    assertNotNull(extId);
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 35 with ClientDetailsEntity

use of org.orcid.persistence.jpa.entities.ClientDetailsEntity in project ORCID-Source by ORCID.

the class ExternalIdentifierManagerTest method testAddExternalIdentifierToClaimedRecordPreserveUserDefaultVisibility.

@Test
public void testAddExternalIdentifierToClaimedRecordPreserveUserDefaultVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PersonExternalIdentifier extId = getExternalIdentifier();
    extId = externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, true);
    extId = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId.getPutCode());
    assertNotNull(extId);
    assertEquals(Visibility.LIMITED, extId.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)149 Test (org.junit.Test)75 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)57 BaseTest (org.orcid.core.BaseTest)51 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)33 Date (java.util.Date)23 Transactional (org.springframework.transaction.annotation.Transactional)16 HashSet (java.util.HashSet)15 DBUnitTest (org.orcid.test.DBUnitTest)15 HashMap (java.util.HashMap)14 Authentication (org.springframework.security.core.Authentication)13 OAuth2Authentication (org.springframework.security.oauth2.provider.OAuth2Authentication)13 OAuth2Request (org.springframework.security.oauth2.provider.OAuth2Request)11 Work (org.orcid.jaxb.model.record_v2.Work)9 Before (org.junit.Before)8 ArrayList (java.util.ArrayList)7 OrcidClient (org.orcid.jaxb.model.clientgroup.OrcidClient)7 ClientSecretEntity (org.orcid.persistence.jpa.entities.ClientSecretEntity)7 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)6 Funding (org.orcid.jaxb.model.record_v2.Funding)6