Search in sources :

Example 96 with Rollback

use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.

the class WebhookDaoTest method testFindWebhooksReadyToProcess.

@Test
@Rollback(true)
public void testFindWebhooksReadyToProcess() {
    Date now = new Date();
    List<WebhookEntity> results = webhookDao.findWebhooksReadyToProcess(now, 5, 10);
    assertNotNull(results);
    assertEquals(1, results.size());
    Set<String> orcids = new HashSet<>();
    for (WebhookEntity result : results) {
        orcids.add(result.getProfile().getId());
    }
    assertTrue(orcids.contains("4444-4444-4444-4443"));
}
Also used : WebhookEntity(org.orcid.persistence.jpa.entities.WebhookEntity) Date(java.util.Date) HashSet(java.util.HashSet) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback)

Example 97 with Rollback

use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.

the class WebhookDaoTest method testCountWebhooksReadyToProcess.

@Test
@Rollback(true)
public void testCountWebhooksReadyToProcess() {
    Date now = new Date();
    long count = webhookDao.countWebhooksReadyToProcess(now, 5);
    assertNotNull(count);
    assertEquals(1, count);
}
Also used : Date(java.util.Date) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback)

Example 98 with Rollback

use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.

the class IdentifierTypeManagerTest method test2CreateAndUpdateIdentifier.

@Test
@Transactional
@Rollback
public void test2CreateAndUpdateIdentifier() {
    IdentifierType id = idTypeMan.createIdentifierType(createIdentifierType(1));
    assertNotNull(id);
    assertNotNull(id.getPutCode());
    assertTrue(new Date().after(id.getDateCreated()));
    id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
    assertNotNull(id);
    id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
    Date last = id.getLastModified();
    id.setValidationRegex("test");
    id = idTypeMan.updateIdentifierType(id);
    assertTrue(last.before(id.getLastModified()));
    id = idTypeMan.fetchIdentifierTypeByDatabaseName("TEST1", null);
    assertEquals("test1", id.getName());
    assertEquals("test", id.getValidationRegex());
    assertTrue(last.getTime() < id.getLastModified().getTime());
}
Also used : IdentifierType(org.orcid.pojo.IdentifierType) Date(java.util.Date) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 99 with Rollback

use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.

the class OrcidIndexManagerImplTest method checkGrantsPersisted.

@Test
@Rollback
public void checkGrantsPersisted() throws Exception {
    OrcidProfile grantsProfileListing = getOrcidWithGrants();
    OrcidSolrDocument grantsListing = solrDocWithFundingTitles();
    orcidIndexManager.persistProfileInformationForIndexing(grantsProfileListing);
    verify(solrDao).persist(eq(grantsListing));
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest) Rollback(org.springframework.test.annotation.Rollback)

Example 100 with Rollback

use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.

the class OrcidOauth2TokenDetailServiceTest method removeAllTokensWithSameScopesTest.

@Test
@Transactional
@Rollback
public void removeAllTokensWithSameScopesTest() {
    //We will test deleting this token
    //Delete
    Long token1Id = createToken(CLIENT_ID_1, "token-1", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update /read-limited", false).getId();
    //Should not delete this        
    Long token2Id = createToken(CLIENT_ID_1, "token-2", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update", false).getId();
    //Should not delete this
    Long token3Id = createToken(CLIENT_ID_1, "token-3", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited", false).getId();
    //Should delete this one since it have the same scopes but in different order
    //Delete
    Long token4Id = createToken(CLIENT_ID_1, "token-4", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited /activities/update", false).getId();
    //Should not delete this since it have one scope more /orcid-profile/read-limited
    Long token5Id = createToken(CLIENT_ID_1, "token-5", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/orcid-profile/read-limited /activities/update /read-limited", false).getId();
    //Should not delete this since it have one scope more /activities/read-limited
    Long token6Id = createToken(CLIENT_ID_1, "token-6", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/read-limited /activities/update /activities/read-limited", false).getId();
    //Should not delete this
    Long token7Id = createToken(CLIENT_ID_1, "token-7", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/person/read-limited", false).getId();
    //Should not delete this since it have several more scopes
    Long token8Id = createToken(CLIENT_ID_1, "token-8", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/funding/read-limited /read-limited /activities/read-limited /orcid-works/create /affiliations/update /activities/update", false).getId();
    //Should remove this since it contains the same scopes
    //Delete
    Long token9Id = createToken(CLIENT_ID_1, "token-9", USER_ORCID, new Date(System.currentTimeMillis() + 100000), "/activities/update /read-limited", false).getId();
    List<OrcidOauth2TokenDetail> activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
    assertNotNull(activeTokens);
    assertEquals(9, activeTokens.size());
    orcidOauth2TokenDetailService.disableAccessToken(token1Id, USER_ORCID);
    activeTokens = orcidOauth2TokenDetailService.findByUserName(USER_ORCID);
    assertEquals(6, activeTokens.size());
    for (OrcidOauth2TokenDetail token : activeTokens) {
        assertThat(token.getId(), allOf(not(token1Id), not(token4Id), not(token9Id)));
        assertThat(token.getId(), anyOf(is(token2Id), is(token3Id), is(token5Id), is(token6Id), is(token7Id), is(token8Id)));
    }
}
Also used : Date(java.util.Date) OrcidOauth2TokenDetail(org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Rollback (org.springframework.test.annotation.Rollback)107 Test (org.junit.Test)103 Transactional (org.springframework.transaction.annotation.Transactional)81 DBUnitTest (org.orcid.test.DBUnitTest)46 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)37 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)25 Date (java.util.Date)24 BaseTest (org.orcid.core.BaseTest)13 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)12 OrcidOauth2TokenDetail (org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail)12 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)11 HashSet (java.util.HashSet)10 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)8 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)8 BaseControllerTest (org.orcid.frontend.web.util.BaseControllerTest)7 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)7 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)7 Claimed (org.orcid.jaxb.model.message.Claimed)6 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)6 ArrayList (java.util.ArrayList)5