Search in sources :

Example 6 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignaturesEmptyEmails.

@Test
public void findSignaturesEmptyEmails() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignatures(new PageRequest(0, 1), Arrays.asList("notorganization"), Collections.emptyList())).isEmpty();
}
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 7 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignatureEmailDomain.

@Test
public void findSignatureEmailDomain() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignature(springCla.getName(), Arrays.asList("notorganization"), user.getEmails())).isNotNull();
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 8 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignatureByEmptyGitHubOrganizations.

@Test
public void findSignatureByEmptyGitHubOrganizations() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignature(springCla.getName(), Arrays.asList(), null)).isNull();
}
Also used : CorporateSignature(io.pivotal.cla.data.CorporateSignature) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 9 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignaturesEmailDomain.

@Test
public void findSignaturesEmailDomain() {
    CorporateSignature emailSignature = createSignature(cla, user);
    emailSignature.setGitHubOrganization(null);
    emailSignature.setEmailDomain("gmail.com");
    emailSignature = signatures.save(emailSignature);
    assertThat(signatures.findSignatures(new PageRequest(0, 1), Arrays.asList("notorganization"), user.getEmails())).hasSize(1);
}
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 10 with CorporateSignature

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

the class CclaController method signCla.

@RequestMapping(value = "/sign/{claName}/ccla", method = RequestMethod.POST)
public String signCla(@AuthenticationPrincipal User user, @Valid SignCorporateClaForm signCorporateClaForm, BindingResult result, Map<String, Object> model, RedirectAttributes redirect) throws Exception {
    ContributorLicenseAgreement cla = clas.findOne(signCorporateClaForm.getClaId());
    List<String> currentUserGitHubOrganizations = gitHub.getOrganizations(user.getGitHubLogin());
    if (result.hasErrors()) {
        model.put("cla", cla);
        signCorporateClaForm.setGitHubOrganizations(currentUserGitHubOrganizations);
        return "cla/ccla/sign";
    }
    CorporateSignature signature = new CorporateSignature();
    signature.setCla(cla);
    signature.setEmail(signCorporateClaForm.getEmail());
    signature.setDateOfSignature(new Date());
    signature.setGitHubLogin(user.getGitHubLogin());
    signature.setGitHubOrganization(signCorporateClaForm.getGitHubOrganization());
    signature.setTitle(signCorporateClaForm.getTitle());
    signature.setCountry(signCorporateClaForm.getCountry());
    signature.setName(signCorporateClaForm.getName());
    signature.setMailingAddress(signCorporateClaForm.getMailingAddress());
    signature.setTelephone(signCorporateClaForm.getTelephone());
    signature.setCompanyName(signCorporateClaForm.getCompanyName());
    corporate.save(signature);
    // update github
    String repositoryId = signCorporateClaForm.getRepositoryId();
    Integer pullRequestId = signCorporateClaForm.getPullRequestId();
    redirect.addAttribute("claName", cla.getName());
    if (repositoryId == null || pullRequestId == null) {
        return "redirect:/sign/{claName}/ccla";
    }
    ClaPullRequestStatusRequest updatePullRequest = signCorporateClaForm.createUpdatePullRequestStatus(user.getGitHubLogin());
    if (updatePullRequest != null) {
        updatePullRequest.getCommitStatus().setSuccess(true);
        claService.savePullRequestStatus(updatePullRequest);
    }
    redirect.addAttribute("repositoryId", repositoryId);
    redirect.addAttribute("pullRequestId", pullRequestId);
    return "redirect:/sign/{claName}/ccla";
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) ClaPullRequestStatusRequest(io.pivotal.cla.service.ClaPullRequestStatusRequest) CorporateSignature(io.pivotal.cla.data.CorporateSignature) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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