use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ClientDetailsManagerTest method testLoadClientByClientId.
@Test
@Rollback
@Transactional
public void testLoadClientByClientId() throws Exception {
List<ClientDetailsEntity> all = clientDetailsManager.getAll();
assertEquals(9, all.size());
for (ClientDetailsEntity clientDetailsEntity : all) {
ClientDetails clientDetails = clientDetailsManager.loadClientByClientId(clientDetailsEntity.getId());
assertNotNull(clientDetails);
if (!"APP-5555555555555555".equals(clientDetailsEntity.getId()) && !"APP-5555555555555556".equals(clientDetailsEntity.getId()) && !"APP-6666666666666666".equals(clientDetailsEntity.getId())) {
checkClientDetails(clientDetails);
}
}
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class ClientDetailsManagerTest method testCreateClientDetailsWithRandomSecret.
@Test
@Rollback
@Transactional
public void testCreateClientDetailsWithRandomSecret() throws Exception {
Set<String> clientScopes = new HashSet<String>();
clientScopes.add("/orcid-profile/create");
Set<String> clientResourceIds = new HashSet<String>();
clientResourceIds.add("orcid-t2-api");
Set<String> clientAuthorizedGrantTypes = new HashSet<String>();
clientAuthorizedGrantTypes.add("client_credentials");
clientAuthorizedGrantTypes.add("authorization_code");
clientAuthorizedGrantTypes.add("refresh_token");
Set<RedirectUri> clientRegisteredRedirectUris = new HashSet<RedirectUri>();
clientRegisteredRedirectUris.add(new RedirectUri("http://www.google.com/"));
List<String> clientGrantedAuthorities = new ArrayList<String>();
clientGrantedAuthorities.add("ROLE_ADMIN");
ClientDetailsEntity clientDetails = clientDetailsManager.createClientDetails("4444-4444-4444-4446", CLIENT_NAME, CLIENT_DESCRIPTION, null, CLIENT_WEBSITE, ClientType.CREATOR, clientScopes, clientResourceIds, clientAuthorizedGrantTypes, clientRegisteredRedirectUris, clientGrantedAuthorities, true);
assertNotNull(clientDetails);
checkClientDetails(clientDetails);
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class FundingsControllerTest method testEditFunding.
@Test
@Rollback(true)
public void testEditFunding() throws Exception {
HttpSession session = mock(HttpSession.class);
when(servletRequest.getSession()).thenReturn(session);
when(localeManager.getLocale()).thenReturn(new Locale("us", "EN"));
FundingForm funding = fundingController.getFundingJson(Long.valueOf("1"));
funding.getFundingTitle().getTitle().setValue("Grant # 1 - updated");
TranslatedTitleForm translatedTitle = new TranslatedTitleForm();
translatedTitle.setContent("Grant # 1 - translated title");
translatedTitle.setLanguageCode("en");
funding.getFundingTitle().setTranslatedTitle(translatedTitle);
funding.getAmount().setValue("3500");
funding.getCurrencyCode().setValue("CRC");
fundingController.postFunding(funding);
// Fetch the funding again
FundingForm updated = fundingController.getFundingJson(Long.valueOf("1"));
assertNotNull(updated);
assertNotNull(updated.getFundingTitle());
assertFalse(PojoUtil.isEmpty(updated.getFundingTitle().getTitle()));
assertEquals("Grant # 1 - updated", updated.getFundingTitle().getTitle().getValue());
assertEquals("Grant # 1 - translated title", updated.getFundingTitle().getTranslatedTitle().getContent());
assertEquals("en", updated.getFundingTitle().getTranslatedTitle().getLanguageCode());
assertFalse(PojoUtil.isEmpty(updated.getFundingType()));
assertEquals("salary-award", updated.getFundingType().getValue());
assertFalse(PojoUtil.isEmpty(updated.getAmount()));
assertEquals("3,500", updated.getAmount().getValue());
assertFalse(PojoUtil.isEmpty(updated.getCurrencyCode()));
assertEquals("CRC", updated.getCurrencyCode().getValue());
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class GroupAdministratorControllerTest method emptyClientTest.
@Test
@Transactional("transactionManager")
@Rollback(true)
public void emptyClientTest() {
Client client = controller.getClient();
client = controller.createClient(client);
assertNotNull(client);
List<String> errors = client.getErrors();
assertEquals(4, errors.size());
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.display_name.empty")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.website.empty")));
assertTrue(errors.contains(controller.getMessage("manage.developer_tools.group.error.short_description.empty")));
assertTrue(errors.contains(controller.getMessage("common.invalid_url")));
}
use of org.springframework.test.annotation.Rollback in project ORCID-Source by ORCID.
the class FundingsControllerTest method testAddFunding.
@Test
@Rollback(true)
public void testAddFunding() throws Exception {
HttpSession session = mock(HttpSession.class);
when(servletRequest.getSession()).thenReturn(session);
when(localeManager.getLocale()).thenReturn(new Locale("us", "EN"));
FundingForm funding = fundingController.getFunding();
funding.setFundingType(Text.valueOf("award"));
FundingTitleForm title = new FundingTitleForm();
title.setTitle(Text.valueOf("Title"));
funding.setFundingTitle(title);
funding.setCountry(Text.valueOf("CR"));
funding.setCity(Text.valueOf("SJ"));
funding.setRegion(Text.valueOf("SJ"));
funding.setAmount(Text.valueOf("1000"));
funding.setCurrencyCode(Text.valueOf("USD"));
funding.setFundingName(Text.valueOf("OrgName"));
FundingForm result = fundingController.postFunding(funding);
assertEquals(funding.getFundingTitle().getTitle(), result.getFundingTitle().getTitle());
assertEquals(funding.getFundingType(), result.getFundingType());
assertEquals(funding.getCountry(), result.getCountry());
assertEquals(funding.getCity(), result.getCity());
assertEquals(funding.getRegion(), result.getRegion());
assertEquals(funding.getCountry(), result.getCountry());
assertNotNull(funding.getErrors());
assertEquals(0, funding.getErrors().size());
BigDecimal expected = fundingController.getAmountAsBigDecimal(funding.getAmount().getValue());
BigDecimal resulting = fundingController.getAmountAsBigDecimal(result.getAmount().getValue());
assertEquals(expected, resulting);
}
Aggregations