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"));
}
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);
}
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());
}
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));
}
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)));
}
}
Aggregations