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