Search in sources :

Example 6 with AdminEditClaPage

use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.

the class EditAdminClaTests method editClaRequiredFieldsIndividualRequired.

@Test
public void editClaRequiredFieldsIndividualRequired() throws Exception {
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    AdminEditClaPage create = AdminEditClaPage.to(getDriver(), cla.getId());
    create = create.form().individual("").submit(AdminEditClaPage.class);
    ClaForm form = create.form();
    form.assertName().hasNoErrors().hasValue(cla.getName());
    form.assertCorporateContent().hasNoErrors();
    form.assertIndividualContent().hasRequiredError();
}
Also used : AdminEditClaPage(io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage) ClaForm(io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm) Test(org.junit.Test)

Example 7 with AdminEditClaPage

use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.

the class EditAdminClaTests method editClaSuccessPrimary.

@Test
public void editClaSuccessPrimary() {
    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).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("Eclipse");
    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 8 with AdminEditClaPage

use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.

the class EditAdminClaTests method editClaSuccessSuperseding.

@Test
public void editClaSuccessSuperseding() {
    ContributorLicenseAgreement springCla = DataUtils.createSpringCla();
    springCla.setId(54321L);
    springCla.setSupersedingCla(cla);
    when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla, springCla));
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockClaRepository.findOne(springCla.getId())).thenReturn(springCla);
    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(), springCla.getId());
    AdminListClasPage successPage = create.form().name("Eclipse").individual(individualMd).corporate(corporateMd).supersedingCla(cla.getId()).submit(AdminListClasPage.class);
    successPage.assertAt();
    ArgumentCaptor<ContributorLicenseAgreement> captor = ArgumentCaptor.forClass(ContributorLicenseAgreement.class);
    verify(mockClaRepository).save(captor.capture());
    ContributorLicenseAgreement saved = captor.getValue();
    assertThat(saved.getId()).isEqualTo(springCla.getId());
    assertThat(saved.getName()).isEqualTo("Eclipse");
    assertThat(saved.isPrimary()).isFalse();
    assertThat(saved.getSupersedingCla()).isSameAs(this.cla);
    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 9 with AdminEditClaPage

use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.

the class EditAdminClaTests method editClaRequiredFieldsAll.

@Test
public void editClaRequiredFieldsAll() throws Exception {
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    AdminEditClaPage edit = AdminEditClaPage.to(getDriver(), cla.getId());
    edit = edit.form().name("").individual("").corporate("").submit(AdminEditClaPage.class);
    ClaForm form = edit.form();
    form.assertName().hasRequiredError();
    form.assertIndividualContent().hasRequiredError();
    form.assertCorporateContent().hasRequiredError();
}
Also used : AdminEditClaPage(io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage) ClaForm(io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm) Test(org.junit.Test)

Example 10 with AdminEditClaPage

use of io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage in project pivotal-cla by pivotalsoftware.

the class EditAdminClaTests method editClaRequiredFieldsCorporateRequired.

@Test
public void editClaRequiredFieldsCorporateRequired() throws Exception {
    when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
    AdminEditClaPage create = AdminEditClaPage.to(getDriver(), cla.getId());
    create = create.form().corporate("").submit(AdminEditClaPage.class);
    ClaForm form = create.form();
    form.assertName().hasNoErrors();
    form.assertIndividualContent().hasNoErrors();
    form.assertCorporateContent().hasRequiredError();
}
Also used : AdminEditClaPage(io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage) ClaForm(io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm) Test(org.junit.Test)

Aggregations

AdminEditClaPage (io.pivotal.cla.webdriver.pages.admin.AdminEditClaPage)11 Test (org.junit.Test)11 ContributorLicenseAgreement (io.pivotal.cla.data.ContributorLicenseAgreement)6 AdminListClasPage (io.pivotal.cla.webdriver.pages.admin.AdminListClasPage)6 ClaForm (io.pivotal.cla.webdriver.pages.admin.AdminClaFormPage.ClaForm)5 HomePage (io.pivotal.cla.webdriver.pages.HomePage)1