Search in sources :

Example 1 with ApplicationConfiguration

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());
}
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 2 with ApplicationConfiguration

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());
}
Also used : File(java.io.File) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) Test(org.junit.Test)

Example 3 with ApplicationConfiguration

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());
    }
}
Also used : IOException(java.io.IOException) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration)

Example 4 with ApplicationConfiguration

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));
}
Also used : ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) TestCaseToApplicationActionConverter(com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter) ApplicationActionConfiguration(com.hribol.automation.core.config.ApplicationActionConfiguration) HashMap(java.util.HashMap) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) ArrayList(java.util.ArrayList) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) Test(org.junit.Test)

Example 5 with ApplicationConfiguration

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());
}
Also used : WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) Test(org.junit.Test)

Aggregations

ApplicationConfiguration (com.hribol.automation.core.config.ApplicationConfiguration)9 Test (org.junit.Test)5 ApplicationActionConfiguration (com.hribol.automation.core.config.ApplicationActionConfiguration)3 IOException (java.io.IOException)3 ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)2 DefaultApplicationActionFactory (com.hribol.automation.core.execution.application.DefaultApplicationActionFactory)2 File (java.io.File)2 HashMap (java.util.HashMap)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 ParameterConfiguration (com.hribol.automation.core.config.ParameterConfiguration)1 WebDriverActionConfiguration (com.hribol.automation.core.config.WebDriverActionConfiguration)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 ArrayList (java.util.ArrayList)1