mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/advanced/TestSystemConfigurationTab.java
@Test
    public void testDeleteFactoryConfigs() throws InterruptedException
    {
        final String factoryPid = "example.asset.ExampleAssetConfig";
        
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        
        Map<String, Object> valuesMap = new HashMap<>();
        valuesMap.put("Activate on startup", true);
        valuesMap.put("Plugin overrides position", true);
        valuesMap.put("Device Power Toggle Name", "Bob");
        ConfigurationHelper.createFactoryConfig(m_Driver, factoryPid, valuesMap);

        WebElement exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
        exampleAssetFactory.findElement(By.cssSelector("span[class='ui-icon ui-icon-plusthick']")).click();

        //Retrieve a list of all factory configs. There should be two.
        List<WebElement> factoryConfigs = exampleAssetFactory.findElements(
                By.cssSelector("div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']"));
        wait.until(ExpectedConditions.visibilityOf(factoryConfigs.get(0)));
        assertThat(factoryConfigs.size(), is(1));
        
        //Verify that the factory configs are actually serial port factory configs.
        for (WebElement config: factoryConfigs)
        {
            WebElement configHeader = config.findElement(By.cssSelector("span[class='ui-panel-title']"));
            assertThat(configHeader.getText().contains(factoryPid), is(true));
        }
        
        //Retrieve the first serial port config.
        WebElement asset1 = factoryConfigs.get(0);
        
        //Retrieve the PID of the first serial port.
        WebElement configHeader = asset1.findElement(By.cssSelector("span[class='ui-panel-title']"));
        String asset1PID = configHeader.getText();
        
        //Delete the first serial port config.
        WebElement deleteConfigButton = asset1.findElement(
                By.cssSelector("button[id*='deleteFactoryConfig']"));
        deleteConfigButton.click();
        
        //Verify canceling the delete.
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, asset1PID, false);
        
        deleteConfigButton.click();
        
        //Actually delete the configuration this time.
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, asset1PID, true);
        
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        
        fwait.until(new ExpectedCondition<Boolean>()
        {

            @Override
            public Boolean apply(final WebDriver driver)
            {
                //Find the event example asset factory.
                WebElement exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
                //Retrieve a list of all example asset configs, verify there are none.
                List<WebElement> factoryConfigs = exampleAssetFactory.findElements(
                        By.cssSelector(
                                "div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']"));
                return factoryConfigs.size() == 0;
            }
        });
        
        //Retrieve the example asset factory so that it might be collapsed.
        exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
        
        //Collapse the example asset factory so that the factory configurations can not be accessed.
        WebElement expandFactory = exampleAssetFactory.findElement(
                By.cssSelector("span[class='ui-icon ui-icon-minusthick']"));
        expandFactory.click();
    }
/**
     * Test deleting factory configurations.
     * Verify the configurations are actually removed.
     */
Test deleting factory configurations.
Verify the configurations are actually removed.
Test deleting factory configurations . Verify the configurations are actually removed .
@Test
    public void testDeleteFactoryConfigs() throws InterruptedException
    {
        final String factoryPid = "example.asset.ExampleAssetConfig";
        WebDriverWait wait = new WebDriverWait(m_Driver, 5);
        Map<String, Object> valuesMap = new HashMap<>();
        valuesMap.put("Activate on startup", true);
        valuesMap.put("Plugin overrides position", true);
        valuesMap.put("Device Power Toggle Name", "Bob");
        ConfigurationHelper.createFactoryConfig(m_Driver, factoryPid, valuesMap);
        WebElement exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
        exampleAssetFactory.findElement(By.cssSelector("span[class='ui-icon ui-icon-plusthick']")).click();
        List<WebElement> factoryConfigs = exampleAssetFactory.findElements(
                By.cssSelector("div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']"));
        wait.until(ExpectedConditions.visibilityOf(factoryConfigs.get(0)));
        assertThat(factoryConfigs.size(), is(1));
        for (WebElement config: factoryConfigs)
        {
            WebElement configHeader = config.findElement(By.cssSelector("span[class='ui-panel-title']"));
            assertThat(configHeader.getText().contains(factoryPid), is(true));
        }
        WebElement asset1 = factoryConfigs.get(0);
        WebElement configHeader = asset1.findElement(By.cssSelector("span[class='ui-panel-title']"));
        String asset1PID = configHeader.getText();
        WebElement deleteConfigButton = asset1.findElement(
                By.cssSelector("button[id*='deleteFactoryConfig']"));
        deleteConfigButton.click();
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, asset1PID, false);
        deleteConfigButton.click();
        ConfigurationHelper.handleDeleteConfigDialog(m_Driver, asset1PID, true);
        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(1, TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, 
                        NoSuchElementException.class);
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(final WebDriver driver)
            {
                WebElement exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
                List<WebElement> factoryConfigs = exampleAssetFactory.findElements(
                        By.cssSelector(
                                "div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']"));
                return factoryConfigs.size() == 0;
            }
        });
        exampleAssetFactory = ConfigurationHelper.findConfigurationPanel(factoryPid, true);
        WebElement expandFactory = exampleAssetFactory.findElement(
                By.cssSelector("span[class='ui-icon ui-icon-minusthick']"));
        expandFactory.click();
    }
@ Test public void testDeleteFactoryConfigs ( ) throws InterruptedException { final String factoryPid = "example.asset.ExampleAssetConfig" ; WebDriverWait wait = new WebDriverWait ( m_Driver , 5 ) ; Map < String , Object > valuesMap = new HashMap < > ( ) ; valuesMap . put ( "Activate on startup" , true ) ; valuesMap . put ( "Plugin overrides position" , true ) ; valuesMap . put ( "Device Power Toggle Name" , "Bob" ) ; ConfigurationHelper . createFactoryConfig ( m_Driver , factoryPid , valuesMap ) ; WebElement exampleAssetFactory = ConfigurationHelper . findConfigurationPanel ( factoryPid , true ) ; exampleAssetFactory . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-plusthick']" ) ) . click ( ) ; List < WebElement > factoryConfigs = exampleAssetFactory . findElements ( By . cssSelector ( "div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']" ) ) ; wait . until ( ExpectedConditions . visibilityOf ( factoryConfigs . get ( 0 ) ) ) ; assertThat ( factoryConfigs . size ( ) , is ( 1 ) ) ; for ( WebElement config : factoryConfigs ) { WebElement configHeader = config . findElement ( By . cssSelector ( "span[class='ui-panel-title']" ) ) ; assertThat ( configHeader . getText ( ) . contains ( factoryPid ) , is ( true ) ) ; } WebElement asset1 = factoryConfigs . get ( 0 ) ; WebElement configHeader = asset1 . findElement ( By . cssSelector ( "span[class='ui-panel-title']" ) ) ; String asset1PID = configHeader . getText ( ) ; WebElement deleteConfigButton = asset1 . findElement ( By . cssSelector ( "button[id*='deleteFactoryConfig']" ) ) ; deleteConfigButton . click ( ) ; ConfigurationHelper . handleDeleteConfigDialog ( m_Driver , asset1PID , false ) ; deleteConfigButton . click ( ) ; ConfigurationHelper . handleDeleteConfigDialog ( m_Driver , asset1PID , true ) ; Wait < WebDriver > fwait = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 1 , TimeUnit . SECONDS ) . ignoring ( StaleElementReferenceException . class , NoSuchElementException . class ) ; fwait . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( final WebDriver driver ) { WebElement exampleAssetFactory = ConfigurationHelper . findConfigurationPanel ( factoryPid , true ) ; List < WebElement > factoryConfigs = exampleAssetFactory . findElements ( By . cssSelector ( "div[class='ui-panel ui-widget ui-widget-content ui-corner-all ui-hidden-container']" ) ) ; return factoryConfigs . size ( ) == 0 ; } } ) ; exampleAssetFactory = ConfigurationHelper . findConfigurationPanel ( factoryPid , true ) ; WebElement expandFactory = exampleAssetFactory . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-minusthick']" ) ) ; expandFactory . click ( ) ; }
Test deleting factory configurations.
Test deleting factory configurations .
//Retrieve a list of all factory configs. There should be two. //Verify that the factory configs are actually serial port factory configs. //Retrieve the first serial port config. //Retrieve the PID of the first serial port. //Delete the first serial port config. //Verify canceling the delete. //Actually delete the configuration this time. //Find the event example asset factory. //Retrieve a list of all example asset configs, verify there are none. //Retrieve the example asset factory so that it might be collapsed. //Collapse the example asset factory so that the factory configurations can not be accessed.