Search in sources :

Example 1 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature in project pivotal-cla by pivotalsoftware.

the class BaseWebDriverTests method setup.

@Before
public void setup() {
    driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(mockMvc).useMockMvcForHosts("github.com").build();
    MarkdownContent corporate = new MarkdownContent();
    corporate.setMarkdown("# Corporate");
    corporate.setHtml("[h1]Corporate[/h1]");
    MarkdownContent individual = new MarkdownContent();
    individual.setMarkdown("# Individual");
    individual.setHtml("[h1]Individual[/h1]");
    cla = new ContributorLicenseAgreement();
    cla.setName("pivotal");
    cla.setCorporateContent(corporate);
    cla.setIndividualContent(individual);
    cla.setId(1L);
    individualSignature = new IndividualSignature();
    individualSignature.setCla(cla);
    individualSignature.setGitHubLogin("rwinch");
    individualSignature.setEmail("rob@gmail.com");
    individualSignature.setName("Rob Winch");
    individualSignature.setMailingAddress("123 Seasame Street");
    individualSignature.setTelephone("123.456.7890");
    corporateSignature = new CorporateSignature();
    corporateSignature.setCla(cla);
    corporateSignature.setGitHubLogin("rwinch");
    corporateSignature.setEmail("rob@gmail.com");
    corporateSignature.setName("Rob Winch");
    corporateSignature.setMailingAddress("123 Seasame Street");
    corporateSignature.setTelephone("123.456.7890");
    corporateSignature.setGitHubOrganization("organization");
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) MarkdownContent(io.pivotal.cla.data.MarkdownContent) CorporateSignature(io.pivotal.cla.data.CorporateSignature) IndividualSignature(io.pivotal.cla.data.IndividualSignature) Before(org.junit.Before)

Example 2 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature in project pivotal-cla by pivotalsoftware.

the class CclaControllerTests method sign.

@Test
public void sign() throws Exception {
    String organization = "pivotal";
    String name = "Rob Winch";
    String email = "rob@gmail.com";
    String address = "123 Seasame St";
    String country = "USA";
    String telephone = "123.456.7890";
    String companyName = "Pivotal";
    String title = "Director";
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring", organization));
    SignCclaPage signPage = SignCclaPage.go(getDriver(), cla.getName());
    signPage = signPage.form().name(name).email(email).mailingAddress(address).country(country).telephone(telephone).companyName(companyName).gitHubOrganization(organization).title(title).confirm().sign(SignCclaPage.class);
    signPage.assertAt();
    ArgumentCaptor<CorporateSignature> signatureCaptor = ArgumentCaptor.forClass(CorporateSignature.class);
    verify(mockCorporateSignatureRepository).save(signatureCaptor.capture());
    CorporateSignature signature = signatureCaptor.getValue();
    assertThat(signature.getCla()).isEqualTo(cla);
    assertThat(signature.getCountry()).isEqualTo(country);
    assertThat(signature.getName()).isEqualTo(name);
    assertThat(signature.getEmail()).isEqualTo(email);
    assertThat(signature.getMailingAddress()).isEqualTo(address);
    assertThat(signature.getTelephone()).isEqualTo(telephone);
    assertThat(signature.getCompanyName()).isEqualTo(companyName);
    assertThat(signature.getGitHubOrganization()).isEqualTo(organization);
    assertThat(signature.getTitle()).isEqualTo(title);
    assertThat(signature.getDateOfSignature()).isCloseTo(new Date(), TimeUnit.SECONDS.toMillis(5));
    verify(mockGitHub, never()).save(any(PullRequestStatus.class));
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) SignCclaPage(io.pivotal.cla.webdriver.pages.SignCclaPage) Matchers.anyString(org.mockito.Matchers.anyString) PullRequestStatus(io.pivotal.cla.service.github.PullRequestStatus) Date(java.util.Date) Test(org.junit.Test)

Example 3 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature in project pivotal-cla by pivotalsoftware.

the class CorporateSignatureRepositoryTests method findSignaturesForMultipleSigned.

@Test
public void findSignaturesForMultipleSigned() {
    CorporateSignature springSignature = createSignature(springCla, user);
    signatures.save(springSignature);
    assertThat(signatures.findSignatures(new PageRequest(0, 4), Arrays.asList(signature.getGitHubOrganization(), springSignature.getGitHubOrganization()), user.getEmails())).hasSize(2);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 4 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature in project pivotal-cla by pivotalsoftware.

the class CorporateSignatureRepositoryTests method createSignature.

private static CorporateSignature createSignature(ContributorLicenseAgreement cla, User user) {
    CorporateSignature signature = DataUtils.cclaSignature(cla);
    signature.setGitHubLogin(user.getGitHubLogin());
    signature.setEmail(user.getEmails().iterator().next());
    return signature;
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature)

Example 5 with CorporateSignature

use of io.pivotal.cla.data.CorporateSignature in project pivotal-cla by pivotalsoftware.

the class CorporateSignatureRepositoryTests method findSignatureForMultipleSigned.

@Test
public void findSignatureForMultipleSigned() {
    CorporateSignature springSignature = createSignature(springCla, user);
    signatures.save(springSignature);
    assertThat(signatures.findSignature(springCla.getName(), Arrays.asList(signature.getGitHubOrganization(), springSignature.getGitHubOrganization()), user.getEmails())).isNotNull();
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Aggregations

CorporateSignature (io.pivotal.cla.data.CorporateSignature)18 Test (org.junit.Test)11 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)10 PageRequest (org.springframework.data.domain.PageRequest)6 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)4 IndividualSignature (io.pivotal.cla.data.IndividualSignature)2 Date (java.util.Date)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 MarkdownContent (io.pivotal.cla.data.MarkdownContent)1 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)1 CorporateSignatureInfo (io.pivotal.cla.service.CorporateSignatureInfo)1 PullRequestStatus (io.pivotal.cla.service.github.PullRequestStatus)1 SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1