Search in sources :

Example 91 with Rollback

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

the class OrcidOauth2AuthorizationDetailsDaoTest method testFindByClientId.

@Test
@Transactional
@Rollback
public void testFindByClientId() throws Exception {
    List<OrcidOauth2TokenDetail> all = orcidOauth2TokenDetailDao.getAll();
    assertEquals(5, all.size());
    for (OrcidOauth2TokenDetail detail : all) {
        List<OrcidOauth2TokenDetail> allForClient = orcidOauth2TokenDetailDao.findByClientId(detail.getClientDetailsId());
        assertEquals(1, allForClient.size());
    }
}
Also used : 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)

Example 92 with Rollback

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

the class OrcidOauth2AuthoriziationCodeDetailDaoTest method testOrcidOauth2AuthoriziationCodeDetailDaoPersist.

@Test
@Transactional
@Rollback
public void testOrcidOauth2AuthoriziationCodeDetailDaoPersist() {
    OrcidOauth2AuthoriziationCodeDetail detail = getOrcidOauth2AuthoriziationCodeDetail();
    orcidOauth2AuthoriziationCodeDetailDao.persist(detail);
    OrcidOauth2AuthoriziationCodeDetail anotherDetail = orcidOauth2AuthoriziationCodeDetailDao.find(detail.getId());
    assertNotNull(anotherDetail);
    checkValues(anotherDetail);
    anotherDetail = orcidOauth2AuthoriziationCodeDetailDao.removeAndReturn(anotherDetail.getId());
    assertNotNull(anotherDetail);
    anotherDetail = orcidOauth2AuthoriziationCodeDetailDao.find(anotherDetail.getId());
    assertNull(anotherDetail);
}
Also used : OrcidOauth2AuthoriziationCodeDetail(org.orcid.persistence.jpa.entities.OrcidOauth2AuthoriziationCodeDetail) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 93 with Rollback

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

the class ProfileDaoTest method testUpdateDefaultVisibility.

@Test
@Rollback(true)
public void testUpdateDefaultVisibility() {
    ProfileEntity entity1 = profileDao.find("1000-0000-0000-0001");
    ProfileEntity entity6 = profileDao.find("0000-0000-0000-0006");
    assertEquals(Visibility.PUBLIC, entity1.getActivitiesVisibilityDefault());
    assertEquals(Visibility.PUBLIC, entity6.getActivitiesVisibilityDefault());
    // Set it private
    assertTrue(profileDao.updateDefaultVisibility("0000-0000-0000-0006", Visibility.PRIVATE));
    entity1 = profileDao.find("1000-0000-0000-0001");
    entity6 = profileDao.find("0000-0000-0000-0006");
    assertEquals(Visibility.PUBLIC, entity1.getActivitiesVisibilityDefault());
    assertEquals(Visibility.PRIVATE, entity6.getActivitiesVisibilityDefault());
    // Set it limited
    assertTrue(profileDao.updateDefaultVisibility("0000-0000-0000-0006", Visibility.LIMITED));
    entity1 = profileDao.find("1000-0000-0000-0001");
    entity6 = profileDao.find("0000-0000-0000-0006");
    assertEquals(Visibility.PUBLIC, entity1.getActivitiesVisibilityDefault());
    assertEquals(Visibility.LIMITED, entity6.getActivitiesVisibilityDefault());
    // Set it public again
    assertTrue(profileDao.updateDefaultVisibility("0000-0000-0000-0006", Visibility.PUBLIC));
    entity1 = profileDao.find("1000-0000-0000-0001");
    entity6 = profileDao.find("0000-0000-0000-0006");
    assertEquals(Visibility.PUBLIC, entity1.getActivitiesVisibilityDefault());
    assertEquals(Visibility.PUBLIC, entity6.getActivitiesVisibilityDefault());
}
Also used : ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback)

Example 94 with Rollback

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

the class ResearcherUrlDaoTest method testfindResearcherUrl.

@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testfindResearcherUrl() {
    ResearcherUrlEntity researcherUrl = researcherUrlDao.getResearcherUrl("4444-4444-4444-4441", 1L);
    assertNotNull(researcherUrl);
    assertEquals("444_1", researcherUrl.getUrlName());
    try {
        researcherUrl = researcherUrlDao.getResearcherUrl("4444-4444-4444-5555", 1L);
        fail();
    } catch (NoResultException e) {
    }
}
Also used : ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) NoResultException(javax.persistence.NoResultException) Test(org.junit.Test) DBUnitTest(org.orcid.test.DBUnitTest) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 95 with Rollback

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

the class ResearcherUrlDaoTest method testAddResearcherUrl.

@Test
@Rollback(true)
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testAddResearcherUrl() {
    assertEquals(6, researcherUrlDao.getResearcherUrls("4444-4444-4444-4443", 0L).size());
    ResearcherUrlEntity newRUrl = new ResearcherUrlEntity();
    newRUrl.setDateCreated(new Date());
    newRUrl.setLastModified(new Date());
    newRUrl.setClientSourceId("APP-5555555555555555");
    newRUrl.setUrl("www.4443.com");
    newRUrl.setUrlName("test");
    newRUrl.setUser(new ProfileEntity("4444-4444-4444-4443"));
    newRUrl.setVisibility(Visibility.PUBLIC);
    newRUrl = researcherUrlDao.merge(newRUrl);
    assertNotNull(newRUrl);
    assertEquals(7, researcherUrlDao.getResearcherUrls("4444-4444-4444-4443", 0L).size());
    for (ResearcherUrlEntity rUrl : researcherUrlDao.getResearcherUrls("4444-4444-4444-4443", 0L)) {
        if ("www.4443.com".equals(rUrl.getUrl())) {
            assertEquals("APP-5555555555555555", rUrl.getElementSourceId());
        }
    }
}
Also used : ResearcherUrlEntity(org.orcid.persistence.jpa.entities.ResearcherUrlEntity) Date(java.util.Date) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) 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)108 Test (org.junit.Test)104 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