Search in sources :

Example 1 with TestCaseToApplicationActionConverter

use of com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter 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 2 with TestCaseToApplicationActionConverter

use of com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter 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)

Aggregations

ApplicationActionConfiguration (com.hribol.automation.core.config.ApplicationActionConfiguration)2 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)2 TestCaseToApplicationActionConverter (com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)1 ApplicationConfiguration (com.hribol.automation.core.config.ApplicationConfiguration)1 ParameterConfiguration (com.hribol.automation.core.config.ParameterConfiguration)1 WebDriverActionConfiguration (com.hribol.automation.core.config.WebDriverActionConfiguration)1 ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)1 DefaultApplicationActionFactory (com.hribol.automation.core.execution.application.DefaultApplicationActionFactory)1 WebDriverActionFactory (com.hribol.automation.core.execution.factory.WebDriverActionFactory)1 ArrayList (java.util.ArrayList)1