Search in sources :

Example 1 with ParameterConfiguration

use of com.hribol.automation.core.config.ParameterConfiguration in project selenium_java by sergueik.

the class WebDriverActionConfigurationTest method webDriverActionConfigurationTest.

@Test
public void webDriverActionConfigurationTest() {
    String webDriverActionType = "CLICK_CLASS_BY_TEXT";
    ParameterConfiguration parameterConfiguration = mock(ParameterConfiguration.class);
    Map<String, ParameterConfiguration> parametersConfiguration = new HashMap<>();
    parametersConfiguration.put("text", parameterConfiguration);
    WebDriverActionConfiguration webDriverActionConfiguration = new WebDriverActionConfiguration();
    webDriverActionConfiguration.setWebDriverActionType(webDriverActionType);
    webDriverActionConfiguration.setParametersConfiguration(parametersConfiguration);
    assertEquals(webDriverActionType, webDriverActionConfiguration.getWebDriverActionType());
    assertEquals(parametersConfiguration, webDriverActionConfiguration.getParametersConfiguration());
}
Also used : HashMap(java.util.HashMap) WebDriverActionConfiguration(com.hribol.automation.core.config.WebDriverActionConfiguration) ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) Test(org.junit.Test)

Example 2 with ParameterConfiguration

use of com.hribol.automation.core.config.ParameterConfiguration in project selenium_java by sergueik.

the class TestCaseToApplicationActionConverterTest method canCreateCorrectAction.

@Test
public void canCreateCorrectAction() {
    String actionType = "CLICK_CLASS_BY_TEXT";
    String text = "text";
    String ATP = "ATP";
    String clickMegaMenu = "clickMegaMenu";
    String megaMenuLink = "mega-menu-link";
    String initialCollectorClass = "initialCollectorClass";
    Map<String, String> testCaseStep = new HashMap<>();
    testCaseStep.put(text, ATP);
    testCaseStep.put(EVENT, clickMegaMenu);
    Map<String, Object> tempMap = new HashMap<>();
    tempMap.put(EVENT, clickMegaMenu);
    tempMap.put(initialCollectorClass, megaMenuLink);
    tempMap.put(EXPECTS_HTTP, false);
    tempMap.put(text, ATP);
    ParameterConfiguration initialCollectorClassParameterConfiguration = mock(ParameterConfiguration.class);
    when(initialCollectorClassParameterConfiguration.getParameterName()).thenReturn(initialCollectorClass);
    when(initialCollectorClassParameterConfiguration.isExposed()).thenReturn(false);
    when(initialCollectorClassParameterConfiguration.getValue()).thenReturn(megaMenuLink);
    ParameterConfiguration textParameterConfiguration = mock(ParameterConfiguration.class);
    when(textParameterConfiguration.getParameterName()).thenReturn(text);
    when(textParameterConfiguration.isExposed()).thenReturn(true);
    when(textParameterConfiguration.getAlias()).thenReturn(text);
    WebDriverAction webDriverAction = mock(WebDriverAction.class);
    WebDriverActionFactory webDriverActionFactory = mock(WebDriverActionFactory.class);
    when(webDriverActionFactory.create(actionType, tempMap)).thenReturn(webDriverAction);
    WebDriverActionConfiguration preconditionActionConfiguration = mock(WebDriverActionConfiguration.class);
    when(preconditionActionConfiguration.getWebDriverActionType()).thenReturn(NOTHING);
    WebDriverActionConfiguration webDriverActionConfiguration = mock(WebDriverActionConfiguration.class);
    when(webDriverActionConfiguration.getWebDriverActionType()).thenReturn(actionType);
    Map<String, ParameterConfiguration> parameterConfigurationMap = new HashMap<>();
    parameterConfigurationMap.put(initialCollectorClass, initialCollectorClassParameterConfiguration);
    parameterConfigurationMap.put(text, textParameterConfiguration);
    when(webDriverActionConfiguration.getParametersConfiguration()).thenReturn(parameterConfigurationMap);
    WebDriverActionConfiguration postconditionActionConfiguration = mock(WebDriverActionConfiguration.class);
    when(postconditionActionConfiguration.getWebDriverActionType()).thenReturn(NOTHING);
    ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class);
    when(applicationActionConfiguration.getConditionBeforeExecution()).thenReturn(preconditionActionConfiguration);
    when(applicationActionConfiguration.getWebDriverAction()).thenReturn(webDriverActionConfiguration);
    when(applicationActionConfiguration.getConditionAfterExecution()).thenReturn(postconditionActionConfiguration);
    when(applicationActionConfiguration.getName()).thenReturn(clickMegaMenu);
    TestCaseToApplicationActionConverter testCaseToApplicationActionConverter = new TestCaseToApplicationActionConverter(webDriverActionFactory);
    ApplicationAction applicationAction = testCaseToApplicationActionConverter.convert(applicationActionConfiguration, testCaseStep);
    assertFalse(applicationAction.getPrecondition().isPresent());
    assertFalse(applicationAction.getPostcondition().isPresent());
    assertTrue(applicationAction.getWebdriverAction().isPresent());
    assertEquals(webDriverAction, applicationAction.getWebdriverAction().get());
}
Also used : TestCaseToApplicationActionConverter(com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter) HashMap(java.util.HashMap) WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction) ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) ApplicationActionConfiguration(com.hribol.automation.core.config.ApplicationActionConfiguration) WebDriverActionConfiguration(com.hribol.automation.core.config.WebDriverActionConfiguration) Test(org.junit.Test)

Example 3 with ParameterConfiguration

use of com.hribol.automation.core.config.ParameterConfiguration in project selenium_java by sergueik.

the class ConfigurationUtilsTest method canDumpApplicationConfiguration.

@Test
public void canDumpApplicationConfiguration() throws IOException {
    ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
    applicationConfiguration.setApplicationName("dummy");
    applicationConfiguration.setVersion("0.0.1");
    ParameterConfiguration parameterConfiguration = new ParameterConfiguration();
    parameterConfiguration.setAlias("text");
    parameterConfiguration.setExpose(true);
    parameterConfiguration.setParameterName("text");
    Map<String, ParameterConfiguration> parameterConfigurationMap = new HashMap<>();
    parameterConfigurationMap.put(parameterConfiguration.getParameterName(), parameterConfiguration);
    WebDriverActionConfiguration webDriverActionConfiguration = new WebDriverActionConfiguration();
    webDriverActionConfiguration.setWebDriverActionType("CLICK_CLASS_BY_TEXT");
    webDriverActionConfiguration.setParametersConfiguration(parameterConfigurationMap);
    ApplicationActionConfiguration applicationActionConfiguration = new ApplicationActionConfiguration();
    applicationActionConfiguration.setName("applicationAction");
    applicationActionConfiguration.setExpectsHttpRequest(false);
    applicationActionConfiguration.setWebDriverAction(webDriverActionConfiguration);
    String outputFileName = "tmp.json";
    ConfigurationUtils.dumpApplicationConfiguration(applicationConfiguration, outputFileName);
    File outputFile = new File(outputFileName);
    assertTrue(outputFile.exists());
    assertTrue(outputFile.delete());
}
Also used : HashMap(java.util.HashMap) ApplicationActionConfiguration(com.hribol.automation.core.config.ApplicationActionConfiguration) WebDriverActionConfiguration(com.hribol.automation.core.config.WebDriverActionConfiguration) ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) File(java.io.File) Test(org.junit.Test)

Example 4 with ParameterConfiguration

use of com.hribol.automation.core.config.ParameterConfiguration in project selenium_java by sergueik.

the class ParameterConfigurationTest method parameterConfigurationGettersAndSetters.

@Test
public void parameterConfigurationGettersAndSetters() {
    String parameterName = "parameterName";
    boolean expose = true;
    String value = "value";
    String alias = "alias";
    ParameterConfiguration parameterConfiguration = new ParameterConfiguration();
    parameterConfiguration.setParameterName(parameterName);
    parameterConfiguration.setExpose(expose);
    parameterConfiguration.setValue(value);
    parameterConfiguration.setAlias(alias);
    assertEquals(parameterName, parameterConfiguration.getParameterName());
    assertEquals(expose, parameterConfiguration.isExposed());
    assertEquals(value, parameterConfiguration.getValue());
    assertEquals(alias, parameterConfiguration.getAlias());
}
Also used : ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) Test(org.junit.Test)

Example 5 with ParameterConfiguration

use of com.hribol.automation.core.config.ParameterConfiguration in project selenium_java by sergueik.

the class TestCaseToApplicationActionConverter method convertAction.

private Optional<WebDriverAction> convertAction(WebDriverActionConfiguration webDriverActionConfiguration, Map<String, String> testCaseStep, boolean expectHttpRequest) {
    String webdriverActionType = webDriverActionConfiguration.getWebDriverActionType();
    if (webdriverActionType.equals(NOTHING)) {
        return Optional.empty();
    }
    Map<String, ParameterConfiguration> parametersConfigurations = webDriverActionConfiguration.getParametersConfiguration();
    Map<String, Object> parameters = new HashMap<>();
    parameters.put(EVENT, testCaseStep.get(EVENT));
    parameters.put(EXPECTS_HTTP, expectHttpRequest);
    for (String parameterName : parametersConfigurations.keySet()) {
        ParameterConfiguration parameterConfiguration = parametersConfigurations.get(parameterName);
        if (parameterConfiguration.isExposed()) {
            String alias = parameterConfiguration.getAlias();
            String value = testCaseStep.get(alias);
            parameters.put(alias, value);
        } else {
            String name = parameterConfiguration.getParameterName();
            String value = parameterConfiguration.getValue();
            parameters.put(name, value);
        }
    }
    WebDriverAction webDriverAction = webDriverActionFactory.create(webdriverActionType, parameters);
    return Optional.of(webDriverAction);
}
Also used : HashMap(java.util.HashMap) ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction)

Aggregations

ParameterConfiguration (com.hribol.automation.core.config.ParameterConfiguration)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 WebDriverActionConfiguration (com.hribol.automation.core.config.WebDriverActionConfiguration)3 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)2 ApplicationActionConfiguration (com.hribol.automation.core.config.ApplicationActionConfiguration)2 ApplicationConfiguration (com.hribol.automation.core.config.ApplicationConfiguration)1 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)1 TestCaseToApplicationActionConverter (com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter)1 WebDriverActionFactory (com.hribol.automation.core.execution.factory.WebDriverActionFactory)1 File (java.io.File)1