mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/advanced/TestSystemConfigurationTab.java
@Test
    public void testCreateConfig() throws InterruptedException
    {
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        
        //open create configuration dialog and get count of existing configurations
        By configTableSelector = By.cssSelector("tbody[id*='factoryConfigTable_data']");
        String rowNum = ConfigurationHelper.createConfigDialogHelper("example.ccomms.ExamplePhysicalLinkConfig", true);
        WebElement configTable = m_Driver.findElement(configTableSelector);
        int originalConfigCount = ConfigurationHelper.getConfigurationsList(rowNum, configTable).size();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id='createFactoryConfig']")));
        WebElement configDialog = m_Driver.findElement(By.cssSelector("div[id='createFactoryConfig']"));
        
        WebElement propsBody = m_Driver.findElement(By.
            cssSelector("form[id='createFactoryForm']>span>div>div>table>tbody"));
        
        // set values
        ConfigurationHelper.updateValue(propsBody, "Read timeout ms", "1999");
        ConfigurationHelper.updateValue(propsBody, "Data bits", "8675309");
        
        //create configuration
        WebElement createButton = configDialog.findElement(By.
                cssSelector("button[id='createFactoryForm:createConfig']"));
        createButton.click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id='createFactoryConfig']")));
        
        //Sleep needed so controller has time to add configuration and send response.
        Thread.sleep(1000);
        
        //get updated element containing factory configuration        
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        rowNum = fwait.until(new ExpectedCondition<String>()
        {
            @Override
            public String apply(WebDriver driver)
            {
                return ConfigurationHelper.createConfigDialogHelper("example.ccomms.ExamplePhysicalLinkConfig", false);
            }
        });
        
        //get list of existing configurations
        configTable = m_Driver.findElement(By.cssSelector("tbody[id*='factoryConfigTable_data']"));
        List<WebElement> configList = ConfigurationHelper.getConfigurationsList(rowNum, configTable);
        int newConfigCount = configList.size();
        
        //ensure that there is 1 new configuration
        assertThat(newConfigCount, is(originalConfigCount+1));
        
        //verify property values are identical to given values
        WebElement newConfig = configList.get(0);
        propsBody = configTable.findElement(By.cssSelector("form[id*='factoryConfigTable:"+ rowNum 
                + "']>div>table>tbody"));
        assertThat(ConfigurationHelper.getInputBoxValue(propsBody, "Read timeout ms"), is("1999"));
        assertThat(ConfigurationHelper.getInputBoxValue(propsBody, "Data bits"), is("8675309"));      
        
        //delete new configuration
        WebElement propsTable = configTable.findElement(By.cssSelector("form[id*='factoryConfigTable:"+ rowNum 
                + "']"));
        WebElement deleteButton = propsTable.findElement(By.cssSelector("button[id$='deleteFactoryConfig']"));
        deleteButton.click();
        
        //pid of new configuration is contained in first token delimited by the newline character
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, newConfig.getText().split("\n")[0].trim(), true);
        
        //Sleep need so controller has time to delete configuration and send response.
        Thread.sleep(1000);
        
        //Retrieve factory so it can be closed.
        WebElement config = fwait.until(new ExpectedCondition<WebElement>()
        {
            @Override
            public WebElement apply(WebDriver driver)
            {
                return ConfigurationHelper.findConfigurationPanel("example.ccomms.ExamplePhysicalLinkConfig", true);
            }
        });
        
        WebElement configPropsTable = 
                config.findElement(By.cssSelector("tbody[class='ui-datatable-data ui-widget-content']"));
        WebElement collapse = config.findElement(By.cssSelector("span[class='ui-icon ui-icon-minusthick']"));
        collapse.click();
        
        //Wait for physical link config panel to collapse.
        Thread.sleep(1000);
        assertThat(configPropsTable.isDisplayed(), is(false));
    }
/**
     * Verify a new configuration can be created from an existing factory configuration. 
     */
Verify a new configuration can be created from an existing factory configuration.
Verify a new configuration can be created from an existing factory configuration .
@Test
    public void testCreateConfig() throws InterruptedException
    {
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        By configTableSelector = By.cssSelector("tbody[id*='factoryConfigTable_data']");
        String rowNum = ConfigurationHelper.createConfigDialogHelper("example.ccomms.ExamplePhysicalLinkConfig", true);
        WebElement configTable = m_Driver.findElement(configTableSelector);
        int originalConfigCount = ConfigurationHelper.getConfigurationsList(rowNum, configTable).size();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div[id='createFactoryConfig']")));
        WebElement configDialog = m_Driver.findElement(By.cssSelector("div[id='createFactoryConfig']"));
        WebElement propsBody = m_Driver.findElement(By.
            cssSelector("form[id='createFactoryForm']>span>div>div>table>tbody"));
        ConfigurationHelper.updateValue(propsBody, "Read timeout ms", "1999");
        ConfigurationHelper.updateValue(propsBody, "Data bits", "8675309");
        WebElement createButton = configDialog.findElement(By.
                cssSelector("button[id='createFactoryForm:createConfig']"));
        createButton.click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div[id='createFactoryConfig']")));
        Thread.sleep(1000);
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        rowNum = fwait.until(new ExpectedCondition<String>()
        {
            @Override
            public String apply(WebDriver driver)
            {
                return ConfigurationHelper.createConfigDialogHelper("example.ccomms.ExamplePhysicalLinkConfig", false);
            }
        });
        configTable = m_Driver.findElement(By.cssSelector("tbody[id*='factoryConfigTable_data']"));
        List<WebElement> configList = ConfigurationHelper.getConfigurationsList(rowNum, configTable);
        int newConfigCount = configList.size();
        assertThat(newConfigCount, is(originalConfigCount+1));
        WebElement newConfig = configList.get(0);
        propsBody = configTable.findElement(By.cssSelector("form[id*='factoryConfigTable:"+ rowNum 
                + "']>div>table>tbody"));
        assertThat(ConfigurationHelper.getInputBoxValue(propsBody, "Read timeout ms"), is("1999"));
        assertThat(ConfigurationHelper.getInputBoxValue(propsBody, "Data bits"), is("8675309"));      
        WebElement propsTable = configTable.findElement(By.cssSelector("form[id*='factoryConfigTable:"+ rowNum 
                + "']"));
        WebElement deleteButton = propsTable.findElement(By.cssSelector("button[id$='deleteFactoryConfig']"));
        deleteButton.click();
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, newConfig.getText().split("\n")[0].trim(), true);
        Thread.sleep(1000);
        WebElement config = fwait.until(new ExpectedCondition<WebElement>()
        {
            @Override
            public WebElement apply(WebDriver driver)
            {
                return ConfigurationHelper.findConfigurationPanel("example.ccomms.ExamplePhysicalLinkConfig", true);
            }
        });
        WebElement configPropsTable = 
                config.findElement(By.cssSelector("tbody[class='ui-datatable-data ui-widget-content']"));
        WebElement collapse = config.findElement(By.cssSelector("span[class='ui-icon ui-icon-minusthick']"));
        collapse.click();
        Thread.sleep(1000);
        assertThat(configPropsTable.isDisplayed(), is(false));
    }
@ Test public void testCreateConfig ( ) throws InterruptedException { WebDriverWait wait = new WebDriverWait ( m_Driver , 5 ) ; By configTableSelector = By . cssSelector ( "tbody[id*='factoryConfigTable_data']" ) ; String rowNum = ConfigurationHelper . createConfigDialogHelper ( "example.ccomms.ExamplePhysicalLinkConfig" , true ) ; WebElement configTable = m_Driver . findElement ( configTableSelector ) ; int originalConfigCount = ConfigurationHelper . getConfigurationsList ( rowNum , configTable ) . size ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "div[id='createFactoryConfig']" ) ) ) ; WebElement configDialog = m_Driver . findElement ( By . cssSelector ( "div[id='createFactoryConfig']" ) ) ; WebElement propsBody = m_Driver . findElement ( By . cssSelector ( "form[id='createFactoryForm']>span>div>div>table>tbody" ) ) ; ConfigurationHelper . updateValue ( propsBody , "Read timeout ms" , "1999" ) ; ConfigurationHelper . updateValue ( propsBody , "Data bits" , "8675309" ) ; WebElement createButton = configDialog . findElement ( By . cssSelector ( "button[id='createFactoryForm:createConfig']" ) ) ; createButton . click ( ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "div[id='createFactoryConfig']" ) ) ) ; Thread . sleep ( 1000 ) ; Wait < WebDriver > fwait = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; rowNum = fwait . until ( new ExpectedCondition < String > ( ) { @ Override public String apply ( WebDriver driver ) { return ConfigurationHelper . createConfigDialogHelper ( "example.ccomms.ExamplePhysicalLinkConfig" , false ) ; } } ) ; configTable = m_Driver . findElement ( By . cssSelector ( "tbody[id*='factoryConfigTable_data']" ) ) ; List < WebElement > configList = ConfigurationHelper . getConfigurationsList ( rowNum , configTable ) ; int newConfigCount = configList . size ( ) ; assertThat ( newConfigCount , is ( originalConfigCount + 1 ) ) ; WebElement newConfig = configList . get ( 0 ) ; propsBody = configTable . findElement ( By . cssSelector ( "form[id*='factoryConfigTable:" + rowNum + "']>div>table>tbody" ) ) ; assertThat ( ConfigurationHelper . getInputBoxValue ( propsBody , "Read timeout ms" ) , is ( "1999" ) ) ; assertThat ( ConfigurationHelper . getInputBoxValue ( propsBody , "Data bits" ) , is ( "8675309" ) ) ; WebElement propsTable = configTable . findElement ( By . cssSelector ( "form[id*='factoryConfigTable:" + rowNum + "']" ) ) ; WebElement deleteButton = propsTable . findElement ( By . cssSelector ( "button[id$='deleteFactoryConfig']" ) ) ; deleteButton . click ( ) ; ConfigurationHelper . handleDeleteConfigDialog ( m_Driver , newConfig . getText ( ) . split ( "\n" ) [ 0 ] . trim ( ) , true ) ; Thread . sleep ( 1000 ) ; WebElement config = fwait . until ( new ExpectedCondition < WebElement > ( ) { @ Override public WebElement apply ( WebDriver driver ) { return ConfigurationHelper . findConfigurationPanel ( "example.ccomms.ExamplePhysicalLinkConfig" , true ) ; } } ) ; WebElement configPropsTable = config . findElement ( By . cssSelector ( "tbody[class='ui-datatable-data ui-widget-content']" ) ) ; WebElement collapse = config . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-minusthick']" ) ) ; collapse . click ( ) ; Thread . sleep ( 1000 ) ; assertThat ( configPropsTable . isDisplayed ( ) , is ( false ) ) ; }
Verify a new configuration can be created from an existing factory configuration.
Verify a new configuration can be created from an existing factory configuration .
//open create configuration dialog and get count of existing configurations // set values //create configuration //Sleep needed so controller has time to add configuration and send response. //get updated element containing factory configuration         //get list of existing configurations //ensure that there is 1 new configuration //verify property values are identical to given values //delete new configuration //pid of new configuration is contained in first token delimited by the newline character //Sleep need so controller has time to delete configuration and send response. //Retrieve factory so it can be closed. //Wait for physical link config panel to collapse.