Search in sources :

Example 16 with CorporateSignature

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

the class CorporateSignatureRepositoryTests method findSignatureEmptyEmails.

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

Example 17 with CorporateSignature

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

the class ClaService method findCorporateSignatureInfoFor.

public CorporateSignatureInfo findCorporateSignatureInfoFor(String claName, User user) {
    List<String> gitHubOrganizations = gitHub.getOrganizations(user.getGitHubLogin());
    CorporateSignature corporateSignature = corporateSignatureRepository.findSignature(claName, gitHubOrganizations, user.getEmails());
    ContributorLicenseAgreement contributorLicenseAgreement = corporateSignature == null ? contributorLicenseAgreementRepository.findByNameAndPrimaryTrue(claName) : corporateSignature.getCla();
    return new CorporateSignatureInfo(contributorLicenseAgreement, corporateSignature, gitHubOrganizations);
}
Also used : ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) CorporateSignature(io.pivotal.cla.data.CorporateSignature)

Example 18 with CorporateSignature

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

the class CorporateSignatureRepository method findSignature.

default CorporateSignature findSignature(String claName, Collection<String> organizations, Collection<String> emails) {
    PageRequest pageable = new PageRequest(0, 1);
    List<String> emailDomains = emails == null || emails.isEmpty() ? EMPTY_LIST_FOR_QUERY : emails.stream().map(e -> e.substring(e.lastIndexOf("@") + 1)).collect(Collectors.toList());
    organizations = organizations.isEmpty() ? EMPTY_LIST_FOR_QUERY : organizations;
    List<CorporateSignature> results = findSignatures(pageable, claName, organizations, emailDomains);
    return results.isEmpty() ? null : results.get(0);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) CorporateSignature(io.pivotal.cla.data.CorporateSignature)

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