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");
}
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);
}
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);
}
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);
}
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";
}
Aggregations