Search in sources :

Example 1 with ContributorLicenseAgreement

use of io.pivotal.cla.data.ContributorLicenseAgreement 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 ContributorLicenseAgreement

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

the class AdminCreateClaTests method createClaSuccessPrimary.

@Test
public void createClaSuccessPrimary() {
    when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla));
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    String individualMd = cla.getIndividualContent().getMarkdown();
    String individualHtml = cla.getIndividualContent().getHtml();
    String corporateMd = cla.getCorporateContent().getMarkdown();
    String corporateHtml = cla.getCorporateContent().getHtml();
    String accessToken = WithAdminUserFactory.create().getAccessToken();
    when(mockGitHub.markdownToHtml(accessToken, individualMd)).thenReturn(individualHtml);
    when(mockGitHub.markdownToHtml(accessToken, corporateMd)).thenReturn(corporateHtml);
    AdminCreateClaPage create = AdminCreateClaPage.to(getDriver());
    AdminListClasPage successPage = create.form().name("Eclipse").individual(individualMd).corporate(corporateMd).primary().submit(AdminListClasPage.class);
    successPage.assertAt();
    ArgumentCaptor<ContributorLicenseAgreement> captor = ArgumentCaptor.forClass(ContributorLicenseAgreement.class);
    verify(mockClaRepository).save(captor.capture());
    ContributorLicenseAgreement cla = captor.getValue();
    assertThat(cla.getName()).isEqualTo("Eclipse");
    assertThat(cla.isPrimary()).isTrue();
    assertThat(cla.getIndividualContent().getHtml()).isEqualTo(individualHtml);
    assertThat(cla.getIndividualContent().getMarkdown()).isEqualTo(individualMd);
    assertThat(cla.getCorporateContent().getHtml()).isEqualTo(corporateHtml);
    assertThat(cla.getCorporateContent().getMarkdown()).isEqualTo(corporateMd);
}
Also used : AdminListClasPage(io.pivotal.cla.webdriver.pages.admin.AdminListClasPage) ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) AdminCreateClaPage(io.pivotal.cla.webdriver.pages.admin.AdminCreateClaPage) Test(org.junit.Test)

Example 3 with ContributorLicenseAgreement

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

the class AdminCreateClaTests method createClaSuccessDescription.

@Test
public void createClaSuccessDescription() {
    when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla));
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    String individualMd = cla.getIndividualContent().getMarkdown();
    String individualHtml = cla.getIndividualContent().getHtml();
    String corporateMd = cla.getCorporateContent().getMarkdown();
    String corporateHtml = cla.getCorporateContent().getHtml();
    String accessToken = WithAdminUserFactory.create().getAccessToken();
    when(mockGitHub.markdownToHtml(accessToken, individualMd)).thenReturn(individualHtml);
    when(mockGitHub.markdownToHtml(accessToken, corporateMd)).thenReturn(corporateHtml);
    AdminCreateClaPage create = AdminCreateClaPage.to(getDriver());
    String description = "ICLA FINAL 072310";
    AdminListClasPage successPage = create.form().name("Eclipse").individual(individualMd).corporate(corporateMd).description(description).submit(AdminListClasPage.class);
    successPage.assertAt();
    successPage.assertAt();
    ArgumentCaptor<ContributorLicenseAgreement> captor = ArgumentCaptor.forClass(ContributorLicenseAgreement.class);
    verify(mockClaRepository).save(captor.capture());
    ContributorLicenseAgreement cla = captor.getValue();
    assertThat(cla.getName()).isEqualTo("Eclipse");
    assertThat(cla.isPrimary()).isFalse();
    assertThat(cla.getDescription()).isEqualTo(description);
    assertThat(cla.getIndividualContent().getHtml()).isEqualTo(individualHtml);
    assertThat(cla.getIndividualContent().getMarkdown()).isEqualTo(individualMd);
    assertThat(cla.getCorporateContent().getHtml()).isEqualTo(corporateHtml);
    assertThat(cla.getCorporateContent().getMarkdown()).isEqualTo(corporateMd);
}
Also used : AdminListClasPage(io.pivotal.cla.webdriver.pages.admin.AdminListClasPage) ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) AdminCreateClaPage(io.pivotal.cla.webdriver.pages.admin.AdminCreateClaPage) Test(org.junit.Test)

Example 4 with ContributorLicenseAgreement

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

the class EditAdminClaTests method editClaSuccessPrimaryExistingButSameId.

@Test
public void editClaSuccessPrimaryExistingButSameId() {
    cla.setId(new Long(1L));
    when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
    when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla));
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    String individualMd = cla.getIndividualContent().getMarkdown();
    String individualHtml = cla.getIndividualContent().getHtml();
    String corporateMd = cla.getCorporateContent().getMarkdown();
    String corporateHtml = cla.getCorporateContent().getHtml();
    String accessToken = WithAdminUserFactory.create().getAccessToken();
    when(mockGitHub.markdownToHtml(accessToken, individualMd)).thenReturn(individualHtml);
    when(mockGitHub.markdownToHtml(accessToken, corporateMd)).thenReturn(corporateHtml);
    AdminEditClaPage create = AdminEditClaPage.to(getDriver(), cla.getId());
    AdminListClasPage successPage = create.form().corporate(corporateMd).primary().submit(AdminListClasPage.class);
    successPage.assertAt();
    ArgumentCaptor<ContributorLicenseAgreement> captor = ArgumentCaptor.forClass(ContributorLicenseAgreement.class);
    verify(mockClaRepository).save(captor.capture());
    ContributorLicenseAgreement saved = captor.getValue();
    assertThat(saved.getName()).isEqualTo(cla.getName());
    assertThat(saved.isPrimary()).isTrue();
    assertThat(saved.getIndividualContent().getHtml()).isEqualTo(individualHtml);
    assertThat(saved.getIndividualContent().getMarkdown()).isEqualTo(individualMd);
    assertThat(saved.getCorporateContent().getHtml()).isEqualTo(corporateHtml);
    assertThat(saved.getCorporateContent().getMarkdown()).isEqualTo(corporateMd);
}
Also used : AdminListClasPage(io.pivotal.cla.webdriver.pages.admin.AdminListClasPage) ContributorLicenseAgreement(io.pivotal.cla.data.ContributorLicenseAgreement) AdminEditClaPage(io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage) Test(org.junit.Test)

Example 5 with ContributorLicenseAgreement

use of io.pivotal.cla.data.ContributorLicenseAgreement 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

ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)24 Test (org.junit.Test)14 AdminListClasPage (io.pivotal.cla.webdriver.pages.admin.AdminListClasPage)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 AdminEditClaPage (io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage)6 CorporateSignature (io.pivotal.cla.data.CorporateSignature)4 AdminCreateClaPage (io.pivotal.cla.webdriver.pages.admin.AdminCreateClaPage)4 IndividualSignature (io.pivotal.cla.data.IndividualSignature)3 MarkdownContent (io.pivotal.cla.data.MarkdownContent)2 ClaPullRequestStatusRequest (io.pivotal.cla.service.ClaPullRequestStatusRequest)2 SignCclaPage (io.pivotal.cla.webdriver.pages.SignCclaPage)2 SignIclaPage (io.pivotal.cla.webdriver.pages.SignIclaPage)2 Date (java.util.Date)2 CorporateSignatureInfo (io.pivotal.cla.service.CorporateSignatureInfo)1 ClaForm (io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm)1 Before (org.junit.Before)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1