use of com.hribol.automation.core.config.ApplicationConfiguration 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.ApplicationConfiguration in project selenium_java by sergueik.
the class ConfigurationUtilsTest method canReadApplicationConfiguration.
@Test
public void canReadApplicationConfiguration() throws IOException {
String filename = getClass().getResource("/tenniskafe.json").getFile();
File file = new File(filename);
ApplicationConfiguration applicationConfiguration = ConfigurationUtils.parseApplicationConfiguration(file);
assertEquals("tenniskafe", applicationConfiguration.getApplicationName());
applicationConfiguration = ConfigurationUtils.parseApplicationConfiguration(filename);
assertEquals("tenniskafe", applicationConfiguration.getApplicationName());
}
use of com.hribol.automation.core.config.ApplicationConfiguration in project selenium_java by sergueik.
the class UpdateCommand method run.
@Override
public void run() {
try {
ApplicationConfiguration applicationConfiguration = ConfigurationUtils.parseApplicationConfiguration(pathToApplicationConfiguration);
textIO = promptUtils.getTextIO();
textIO.getTextTerminal().println("Let's update the configuration!");
promptUtils.promptForApplicationName(applicationConfiguration);
promptUtils.updateApplicationConfiguration(applicationConfiguration);
String outputFilename = textIO.newStringInputReader().read("Where should I save the configuration");
ConfigurationUtils.dumpApplicationConfiguration(applicationConfiguration, outputFilename);
} catch (IOException e) {
textIO.getTextTerminal().print(e.getMessage());
}
}
use of com.hribol.automation.core.config.ApplicationConfiguration in project selenium_java by sergueik.
the class DefaultApplicationActionFactoryTest method canCreatePageLoadingAndOtherActions.
@Test
public void canCreatePageLoadingAndOtherActions() {
String url = "http://tenniskafe.com";
String actionName = "actionName";
ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class);
when(applicationActionConfiguration.getName()).thenReturn(actionName);
List<ApplicationActionConfiguration> applicationActionConfigurationList = new ArrayList<>();
applicationActionConfigurationList.add(applicationActionConfiguration);
ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class);
when(applicationConfiguration.getApplicationActionConfigurationList()).thenReturn(applicationActionConfigurationList);
TestCaseToApplicationActionConverter testCaseToApplicationActionConverter = mock(TestCaseToApplicationActionConverter.class);
ApplicationAction applicationAction = mock(ApplicationAction.class);
Map<String, String> testCaseStep = new HashMap<>();
testCaseStep.put("event", actionName);
when(testCaseToApplicationActionConverter.convert(applicationActionConfiguration, testCaseStep)).thenReturn(applicationAction);
ApplicationActionFactory applicationActionFactory = new DefaultApplicationActionFactory(url, applicationConfiguration, testCaseToApplicationActionConverter);
ApplicationAction initialPageLoading = applicationActionFactory.getInitialPageLoading();
assertFalse(initialPageLoading.getPrecondition().isPresent());
assertEquals(applicationAction, applicationActionFactory.create(testCaseStep));
}
use of com.hribol.automation.core.config.ApplicationConfiguration in project selenium_java by sergueik.
the class DefaultApplicationActionFactoryTest method canCreatePageLoading.
@Test
public void canCreatePageLoading() {
String url = "http://tenniskafe.com";
String applicationName = "tenniskafe";
ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class);
when(applicationConfiguration.getApplicationName()).thenReturn(applicationName);
WebDriverActionFactory webDriverActionFactory = mock(WebDriverActionFactory.class);
ApplicationActionFactory applicationActionFactory = new DefaultApplicationActionFactory(url, applicationConfiguration, webDriverActionFactory);
assertFalse(applicationActionFactory.getInitialPageLoading().getPrecondition().isPresent());
assertFalse(applicationActionFactory.getInitialPageLoading().getPostcondition().isPresent());
}
Aggregations