Search in sources :

Example 36 with ClientDetailsEntity

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

the class ExternalIdentifierManagerTest method displayIndexIsSetTo_1_FromUI.

@Test
public void displayIndexIsSetTo_1_FromUI() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PersonExternalIdentifier extId = getExternalIdentifier();
    extId.setType(extId.getType() + System.currentTimeMillis());
    PersonExternalIdentifier extId1 = externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, false);
    extId1 = externalIdentifierManager.getExternalIdentifier(claimedOrcid, extId1.getPutCode());
    assertNotNull(extId1);
    assertEquals(Long.valueOf(1), extId1.getDisplayIndex());
}
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 37 with ClientDetailsEntity

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

the class NotificationManagerTest method testCreateCustomNotification.

@Test
public void testCreateCustomNotification() {
    SourceEntity sourceEntity = new SourceEntity(new ClientDetailsEntity("APP-5555555555555555"));
    when(sourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
    when(sourceManager.retrieveSourceOrcid()).thenReturn("APP-5555555555555555");
    String testOrcid = "0000-0000-0000-0003";
    NotificationCustom notification = new NotificationCustom();
    notification.setSubject("Test subject");
    notification.setLang("en-gb");
    Notification result = notificationManager.createNotification(testOrcid, notification);
    assertNotNull(result);
    assertTrue(result instanceof NotificationCustom);
    NotificationCustom customResult = (NotificationCustom) result;
    assertEquals("Test subject", customResult.getSubject());
    assertEquals("en-gb", customResult.getLang());
}
Also used : NotificationCustom(org.orcid.jaxb.model.notification.custom_v2.NotificationCustom) ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Notification(org.orcid.jaxb.model.notification_v2.Notification) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 38 with ClientDetailsEntity

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

the class IdentifierTypeManagerTest method createIdentifierType.

private IdentifierType createIdentifierType(int seed) {
    IdentifierType id = new IdentifierType();
    id.setName("test" + seed);
    id.setDeprecated(true);
    id.setResolutionPrefix("prefix" + seed);
    id.setValidationRegex("validation" + seed);
    id.setDateCreated(new Date(10, 10, 10));
    id.setLastModified(new Date(11, 11, 11));
    ClientDetailsEntity client = new ClientDetailsEntity();
    client.setClientName(CLIENT_1_ID);
    id.setSourceClient(client);
    id.setPrimaryUse("pu" + seed);
    id.setCaseSensitive(true);
    return id;
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date)

Example 39 with ClientDetailsEntity

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

the class InstitutionalSignInManagerTest method testDontSendNotificationIfClientKnowUser.

@Test
public void testDontSendNotificationIfClientKnowUser() throws UnsupportedEncodingException {
    ClientDetailsEntity testClient = new ClientDetailsEntity(clientId);
    when(mock_userConnectionDao.findByProviderIdAndProviderUserIdAndIdType(anyString(), anyString(), anyString())).thenReturn(null);
    when(mock_clientDetailsEntityCacheManager.retrieveByIdP(anyString())).thenReturn(testClient);
    when(mock_orcidOauth2TokenDetailService.doesClientKnowUser(anyString(), anyString())).thenReturn(true);
    institutionalSignInManager.createUserConnectionAndNotify("idType", "remoteUserId", "displayName", "providerId", userOrcid, Collections.<String, String>emptyMap());
    verify(mock_userConnectionDao, times(1)).persist(any());
    verify(mock_notificationManager, never()).sendAcknowledgeMessage(userOrcid, clientId);
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Test(org.junit.Test)

Example 40 with ClientDetailsEntity

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

the class PeerReviewManagerTest method testAddPeerReviewToClaimedRecordPreserveUserDefaultVisibility.

@Test
public void testAddPeerReviewToClaimedRecordPreserveUserDefaultVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    PeerReview peer = getPeerReview(null);
    peer = peerReviewManager.createPeerReview(claimedOrcid, peer, true);
    peer = peerReviewManager.getPeerReview(claimedOrcid, peer.getPutCode());
    assertNotNull(peer);
    assertEquals(Visibility.LIMITED, peer.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) 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