package org.jboss.hal.testsuite.test.configuration.web;

import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.hal.testsuite.category.Standalone;
import org.jboss.hal.testsuite.cli.CliClient;
import org.jboss.hal.testsuite.cli.CliClientFactory;
import org.jboss.hal.testsuite.page.config.WebServicesPage;
import org.jboss.hal.testsuite.test.util.ConfigAreaChecker;
import org.jboss.hal.testsuite.util.Console;
import org.jboss.hal.testsuite.util.ResourceVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

import static org.jboss.hal.testsuite.cli.CliConstants.WEB_SERVICES_SUBSYSTEM_ADDRESS;


/**
 * @author mkrajcov <mkrajcov@redhat.com>
 */
@RunWith(Arquillian.class)
@Category(Standalone.class)
public class WebServicesTestCase {

    private static final String MODIFY_SOAP_ADDRESS_ID = "modifyAddress";
    private static final String MODIFY_SOAP_ADDRESS_DMR = "modify-wsdl-address";
    private static final String WSDL_HOST_ID = "wsdlHost";
    private static final String WSDL_PORT_ID = "wsdlPort";
    private static final String WSDL_SECURE_PORT_ID = "wsdlSecurePort";

    private static final String PORT_VALUE = "50";
    private static final String PORT_VALUE_NEGATIVE = "-50";
    private static final String SIMPLE_IP = "127.0.0.2";

    private CliClient client = CliClientFactory.getClient();
    private ResourceVerifier verifier = new ResourceVerifier(WEB_SERVICES_SUBSYSTEM_ADDRESS, client);
    private ConfigAreaChecker checker = new ConfigAreaChecker(verifier);

    @Drone
    public WebDriver browser;

    @Page
    public WebServicesPage page;

    @Before
    public void before() {
        Console.withBrowser(browser).refreshAndNavigate(WebServicesPage.class);
    }

    @Test
    public void modifySoapAddress() {
        checker.editCheckboxAndAssert(page, MODIFY_SOAP_ADDRESS_ID, false).dmrAttribute(MODIFY_SOAP_ADDRESS_DMR).invoke();
        checker.editCheckboxAndAssert(page, MODIFY_SOAP_ADDRESS_ID, true).dmrAttribute(MODIFY_SOAP_ADDRESS_DMR).invoke();
    }

    @Test
    public void setWsdlPort() {
        checker.editTextAndAssert(page, WSDL_PORT_ID, PORT_VALUE).invoke();
    }

    @Test
    public void setWsdlPortNegative() {
        checker.editTextAndAssert(page, WSDL_PORT_ID, PORT_VALUE_NEGATIVE).expectError().invoke();
    }

    @Test
    public void setWsdlSecurePort() {
        checker.editTextAndAssert(page, WSDL_SECURE_PORT_ID, PORT_VALUE).invoke();
    }

    @Test
    public void setWsdlSecurePortNegative() {
        checker.editTextAndAssert(page, WSDL_SECURE_PORT_ID, PORT_VALUE_NEGATIVE).expectError().invoke();
    }

    @Test
    public void setWsdlHostSimpleIP() {
        checker.editTextAndAssert(page, WSDL_HOST_ID, SIMPLE_IP).invoke();
    }

}

@@ -347,24 +347,254 @@
 entFactory;%0A
+import org.jboss.hal.testsuite.finder.Application;%0Aimport org.jboss.hal.testsuite.finder.FinderNames;%0Aimport org.jboss.hal.testsuite.finder.FinderNavigation;%0Aimport org.jboss.hal.testsuite.page.config.StandaloneConfigurationPage;%0A
 import org.j
@@ -705,53 +705,8 @@
 er;%0A
-import org.jboss.hal.testsuite.util.Console;%0A
 impo
@@ -1211,86 +1211,8 @@
 RESS
-_ID = %22modifyAddress%22;%0A    private static final String MODIFY_SOAP_ADDRESS_DMR
  = %22
@@ -1274,27 +1274,24 @@
 SDL_HOST
-_ID
  = %22wsdl
 Host%22;%0A 
@@ -1282,17 +1282,18 @@
  = %22wsdl
-H
+-h
 ost%22;%0A  
@@ -1331,27 +1331,24 @@
 SDL_PORT
-_ID
  = %22wsdl
 Port%22;%0A 
@@ -1339,17 +1339,18 @@
  = %22wsdl
-P
+-p
 ort%22;%0A  
@@ -1399,19 +1399,16 @@
 PORT
-_ID
  = %22wsdl
 Secu
@@ -1403,23 +1403,25 @@
  = %22wsdl
-S
+-s
 ecure
-P
+-p
 ort%22;%0A%0A 
@@ -1963,67 +1963,216 @@
     
-Console.withBrowser(browser).refreshAndNavigate(
+new FinderNavigation(browser, StandaloneConfigurationPage.class)%0A                .addAddress(FinderNames.CONFIGURATION, FinderNames.SUBSYSTEMS)%0A                .addAddress(FinderNames.SUBSYSTEM, %22
 Web
+ 
 Services
 Page
@@ -2167,26 +2167,128 @@
 Services
-Page.class
+%22)%0A                .selectRow()%0A                .invoke(FinderNames.VIEW);%0A        Application.waitUntilVisible(
 );%0A    %7D
@@ -2400,19 +2400,16 @@
 _ADDRESS
-_ID
 , false)
@@ -2433,36 +2433,32 @@
 IFY_SOAP_ADDRESS
-_DMR
 ).invoke();%0A    
@@ -2516,19 +2516,16 @@
 _ADDRESS
-_ID
 , true).
@@ -2560,12 +2560,8 @@
 RESS
-_DMR
 ).in
@@ -2658,35 +2658,32 @@
 (page, WSDL_PORT
-_ID
 , PORT_VALUE).in
@@ -2792,27 +2792,24 @@
 e, WSDL_PORT
-_ID
 , PORT_VALUE
@@ -2946,35 +2946,32 @@
 WSDL_SECURE_PORT
-_ID
 , PORT_VALUE).in
@@ -3097,19 +3097,16 @@
 URE_PORT
-_ID
 , PORT_V
@@ -3254,11 +3254,8 @@
 HOST
-_ID
 , SI
@@ -3279,11 +3279,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Fix WebServicesTestCase