use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.
the class EditAdminClaTests method editClaSuccess.
@Test
public void editClaSuccess() {
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().name("Eclipse").individual(individualMd).corporate(corporateMd).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("Eclipse");
assertThat(saved.isPrimary()).isFalse();
assertThat(saved.getDescription()).isNull();
assertThat(saved.getSupersedingCla()).isNull();
assertThat(saved.getIndividualContent().getHtml()).isEqualTo(individualHtml);
assertThat(saved.getIndividualContent().getMarkdown()).isEqualTo(individualMd);
assertThat(saved.getCorporateContent().getHtml()).isEqualTo(corporateHtml);
assertThat(saved.getCorporateContent().getMarkdown()).isEqualTo(corporateMd);
}
Aggregations