<commit_before>package com.autonomy.abc.connections.wizard.configuration;

import com.autonomy.abc.config.TestConfig;
import com.autonomy.abc.connections.wizard.ConnectorTypeStepBase;
import com.autonomy.abc.selenium.config.ApplicationType;
import com.autonomy.abc.selenium.element.FormInput;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorConfigStepTab;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorType;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorTypeStepTab;
import com.hp.autonomy.frontend.selenium.util.AppElement;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Platform;

import static  com.autonomy.abc.framework.ABCAssert.assertThat;
import static com.autonomy.abc.matchers.ElementMatchers.disabled;
import static com.autonomy.abc.matchers.ElementMatchers.hasAttribute;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.hamcrest.core.Is.is;
import static org.openqa.selenium.lift.Matchers.displayed;

/**
 * Created by avidan on 02-11-15.
 */
public class ScheduleStepITCase extends ConnectorTypeStepBase {
    public ScheduleStepITCase(TestConfig config, String browser, ApplicationType type, Platform platform) {
        super(config, browser, type, platform);
    }

    private ConnectorConfigStepTab connectorConfigStep;

    @Before
    public void navigateToStep() {
        ConnectorTypeStepTab connectorTypeStep = newConnectionPage.getConnectorTypeStep();

        FormInput connectorName = connectorTypeStep.connectorName();
        selectConnectorType(ConnectorType.DROPBOX);

        connectorName.setValue("name");
        newConnectionPage.loadOrFadeWait();

        newConnectionPage.nextButton().click();
        newConnectionPage.loadOrFadeWait();

        connectorConfigStep = newConnectionPage.getConnectorConfigStep();

    }

    @Test
    public void validateSchedulingFormInputs() {
        assertThat("The scheduling form is displayed by default", connectorConfigStep.scheduleForm(), displayed());
        assertThat("The 'Run indefinitely' checkbox is checked by default", AppElement.getParent(connectorConfigStep.unlimitedOccurrencesCheckBox()), hasAttribute("aria-checked", equalToIgnoringCase("true")));
        assertThat("The 'Run definitely' checkbox isn't checked by default", AppElement.getParent(connectorConfigStep.limitedOccurrencesCheckBox()), hasAttribute("aria-checked", equalToIgnoringCase("false")));
        assertThat("The repeating input is disabled default ", connectorConfigStep.occurrencesInput().getElement(), disabled());
    }

    @Test
    //CSA-1694
    public void testConnectionSchedulingValidation() {
        connectionsPage.newConnectionButton().click();
        newConnectionPage = getElementFactory().getNewConnectionPage();

        ConnectorTypeStepTab connectorTypeStepTab = newConnectionPage.getConnectorTypeStep();
        connectorTypeStepTab.connectorUrl().setAndSubmit("http://www.bbc.co.uk");
        connectorTypeStepTab.connectorName().setAndSubmit("bbc");

        newConnectionPage.nextButton().click();

        ConnectorConfigStepTab connectorConfigStepTab = newConnectionPage.getConnectorConfigStep();

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), not(containsString("active")));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Run the connector every 1 day"));

        connectorConfigStepTab.hoursButton().click();

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Connector can be scheduled to run every 6 hours at minimum"));

        connectorConfigStepTab.timeIntervalInput().setAndSubmit("6");

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Run the connector every 6 hours"));<commit_msg>Take out navigating to step as is now done in the ScheduleStepITCase Set Up<commit_after>package com.autonomy.abc.connections.wizard.configuration;

import com.autonomy.abc.config.TestConfig;
import com.autonomy.abc.connections.wizard.ConnectorTypeStepBase;
import com.autonomy.abc.selenium.config.ApplicationType;
import com.autonomy.abc.selenium.element.FormInput;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorConfigStepTab;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorType;
import com.autonomy.abc.selenium.page.connections.wizard.ConnectorTypeStepTab;
import com.hp.autonomy.frontend.selenium.util.AppElement;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.Platform;

import static  com.autonomy.abc.framework.ABCAssert.assertThat;
import static com.autonomy.abc.matchers.ElementMatchers.disabled;
import static com.autonomy.abc.matchers.ElementMatchers.hasAttribute;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.equalToIgnoringCase;
import static org.hamcrest.core.Is.is;
import static org.openqa.selenium.lift.Matchers.displayed;

/**
 * Created by avidan on 02-11-15.
 */
public class ScheduleStepITCase extends ConnectorTypeStepBase {
    public ScheduleStepITCase(TestConfig config, String browser, ApplicationType type, Platform platform) {
        super(config, browser, type, platform);
    }

    private ConnectorConfigStepTab connectorConfigStep;

    @Before
    public void navigateToStep() {
        ConnectorTypeStepTab connectorTypeStep = newConnectionPage.getConnectorTypeStep();

        FormInput connectorName = connectorTypeStep.connectorName();
        selectConnectorType(ConnectorType.DROPBOX);

        connectorName.setValue("name");
        newConnectionPage.loadOrFadeWait();

        newConnectionPage.nextButton().click();
        newConnectionPage.loadOrFadeWait();

        connectorConfigStep = newConnectionPage.getConnectorConfigStep();

    }

    @Test
    public void validateSchedulingFormInputs() {
        assertThat("The scheduling form is displayed by default", connectorConfigStep.scheduleForm(), displayed());
        assertThat("The 'Run indefinitely' checkbox is checked by default", AppElement.getParent(connectorConfigStep.unlimitedOccurrencesCheckBox()), hasAttribute("aria-checked", equalToIgnoringCase("true")));
        assertThat("The 'Run definitely' checkbox isn't checked by default", AppElement.getParent(connectorConfigStep.limitedOccurrencesCheckBox()), hasAttribute("aria-checked", equalToIgnoringCase("false")));
        assertThat("The repeating input is disabled default ", connectorConfigStep.occurrencesInput().getElement(), disabled());
    }

    @Test
    //CSA-1694
    public void testConnectionSchedulingValidation() {
        ConnectorConfigStepTab connectorConfigStepTab = newConnectionPage.getConnectorConfigStep();

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), not(containsString("active")));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Run the connector every 1 day"));

        connectorConfigStepTab.hoursButton().click();

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Connector can be scheduled to run every 6 hours at minimum"));

        connectorConfigStepTab.timeIntervalInput().setAndSubmit("6");

        assertThat(connectorConfigStepTab.scheduleForm().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.hoursButton().getAttribute("class"), containsString("active"));
        assertThat(connectorConfigStepTab.daysButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.weeksButton().getAttribute("class"),not(containsString("active")));
        assertThat(connectorConfigStepTab.unlimitedOccurrencesCheckBox().isEnabled(), is(true));
        assertThat(connectorConfigStepTab.scheduleString(), is("Run the connector every 6 hours"));
{'fraction_non_alphanumeric': 0.11372549019607843, 'fraction_numerical': 0.0027450980392156863, 'mean_word_length': 5.796135909393738, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7666322', 'n_tokens_mistral': 2640, 'n_tokens_neox': 2591, 'n_words': 411}