mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/asset/TestAssetConfigurationDialog.java
@Test
    public void testAssetConfiguration() throws InterruptedException
    {
        NavigationHelper.collapseSideBars(m_Driver);
        AssetHelper.createAsset(m_Driver, "ExampleAsset", "testExampleAsset");
        
        NavigationHelper.collapseSideBars(m_Driver);
        
        //---bring up configuration dialog---
        WebElement configButton = m_Driver.findElement(By.cssSelector("button[id*='configurationButton']"));
        configButton.click();
        
        WebDriverWait wait = new WebDriverWait(m_Driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        
        WebElement configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        
        //---verify header is visible---
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        
        WebElement configDialogHeader = configDialog.findElement(By.cssSelector("span[class='ui-dialog-title']"));
        assertThat(configDialogHeader.getText(), is("Asset Configuration"));
        
        //---verify configuration values section is correct---
        //verify values in dialog match expected values
        By selector = By.id("assetEditConfiguration");
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Activate on startup", 
                "Determines whether the asset should be activated during startup (Boolean)");
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Plugin overrides position",
                "When this property is false, position is managed by the core for the asset instance. When true, "
              + "position will be managed by the plug-in. (Boolean)");
        
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Device Power Toggle Name",
                "Name of device power toggle to use (String)");
        
        WebElement configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        
        // verify default values
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"),
                    is("invalid, update this value!"));

        // update config values
        ConfigurationHelper.updateValue(configTable, "Activate on startup", true);
        ConfigurationHelper.updateValue(configTable, "Plugin overrides position", true);
        ConfigurationHelper.updateValue(configTable, "Device Power Toggle Name", "powerName");
        ConfigurationHelper.updateValue(configTable, "Example choice", "Option b");
        
        //---save the configuration and verify that the values persist---
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        WebElement saveConfig = configDialog.findElement(By.cssSelector("button[id*='saveConfig']"));
        saveConfig.click();
        
        //verify dialog is closed
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("button[id*='saveConfig']")));
        
        //TODO TH-1265 problem with clicking this element right away
        Thread.sleep(5000);
        //---bring up configuration dialog---
        m_Driver.findElement(By.cssSelector("button[id*='configurationButton']")).click();
        
        //---verify header is visible---
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));     
        
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        
        // verify value persisted before
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Activate on startup"), is(true));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Plugin overrides position"), is(true));
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"), is("powerName"));
        assertThat(ConfigurationHelper.getSelectOneListBoxValue(configTable, "Example choice"), is("Option b"));
        
        // set to new value
        ConfigurationHelper.updateValue(configTable, "Activate on startup", false);
        ConfigurationHelper.updateValue(configTable, "Plugin overrides position", false);
        ConfigurationHelper.updateValue(configTable, "Device Power Toggle Name", "failText");
        ConfigurationHelper.updateValue(configTable, "Example choice", "Option c");
        
        //---verify cancellation of config does not persist new values---
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        WebElement cancelConfig = configDialog.findElement(By.cssSelector("button[id*='cancelConfig']"));
        cancelConfig.click();
        
        //verify dialog is closed
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='configurationButton']")));
        
        //used to bring up the configuration dialog again after saving configuration due to staleness
        //of elements caused from updates
        Wait<WebDriver> configUpdate = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(NoSuchElementException.class, 
                        StaleElementReferenceException.class);
        
        configUpdate.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                //---bring up configuration dialog---
                WebElement configButton = m_Driver.findElement(By.cssSelector("button[id*='configurationButton']"));
                configButton.click();
                
                return true;
            }
        });
        
        //---verify header is visible---
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        
        // verify value persisted from before
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Activate on startup"), is(true));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Plugin overrides position"), is(true));
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"), is("powerName"));
        assertThat(ConfigurationHelper.getSelectOneListBoxValue(configTable, "Example choice"), is("Option b"));

        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        cancelConfig = configDialog.findElement(By.cssSelector("button[id*='cancelConfig']"));
        cancelConfig.click();
    }
/**
     * Verify configuration dialog can correctly set configuration values for all properties for the asset. 
     * Verify that canceling the dialog will clear out all changed values.
     * *Not testing uuid because there seems to be a problem with changing a uuid*
     */
Verify configuration dialog can correctly set configuration values for all properties for the asset.
Verify that canceling the dialog will clear out all changed values.
*Not testing uuid because there seems to be a problem with changing a uuid
Verify configuration dialog can correctly set configuration values for all properties for the asset . Verify that canceling the dialog will clear out all changed values . * Not testing uuid because there seems to be a problem with changing a uuid
@Test
    public void testAssetConfiguration() throws InterruptedException
    {
        NavigationHelper.collapseSideBars(m_Driver);
        AssetHelper.createAsset(m_Driver, "ExampleAsset", "testExampleAsset");
        NavigationHelper.collapseSideBars(m_Driver);
        WebElement configButton = m_Driver.findElement(By.cssSelector("button[id*='configurationButton']"));
        configButton.click();
        WebDriverWait wait = new WebDriverWait(m_Driver, 30);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        WebElement configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        WebElement configDialogHeader = configDialog.findElement(By.cssSelector("span[class='ui-dialog-title']"));
        assertThat(configDialogHeader.getText(), is("Asset Configuration"));
        By selector = By.id("assetEditConfiguration");
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Activate on startup", 
                "Determines whether the asset should be activated during startup (Boolean)");
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Plugin overrides position",
                "When this property is false, position is managed by the core for the asset instance. When true, "
              + "position will be managed by the plug-in. (Boolean)");
        ConfigurationHelper.verifyDialogValues(m_Driver, selector, "Device Power Toggle Name",
                "Name of device power toggle to use (String)");
        WebElement configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"),
                    is("invalid, update this value!"));
        ConfigurationHelper.updateValue(configTable, "Activate on startup", true);
        ConfigurationHelper.updateValue(configTable, "Plugin overrides position", true);
        ConfigurationHelper.updateValue(configTable, "Device Power Toggle Name", "powerName");
        ConfigurationHelper.updateValue(configTable, "Example choice", "Option b");
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        WebElement saveConfig = configDialog.findElement(By.cssSelector("button[id*='saveConfig']"));
        saveConfig.click();
        wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("button[id*='saveConfig']")));
        Thread.sleep(5000);
        m_Driver.findElement(By.cssSelector("button[id*='configurationButton']")).click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));     
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Activate on startup"), is(true));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Plugin overrides position"), is(true));
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"), is("powerName"));
        assertThat(ConfigurationHelper.getSelectOneListBoxValue(configTable, "Example choice"), is("Option b"));
        ConfigurationHelper.updateValue(configTable, "Activate on startup", false);
        ConfigurationHelper.updateValue(configTable, "Plugin overrides position", false);
        ConfigurationHelper.updateValue(configTable, "Device Power Toggle Name", "failText");
        ConfigurationHelper.updateValue(configTable, "Example choice", "Option c");
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        WebElement cancelConfig = configDialog.findElement(By.cssSelector("button[id*='cancelConfig']"));
        cancelConfig.click();
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("button[id*='configurationButton']")));
        Wait<WebDriver> configUpdate = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).
                pollingEvery(2, TimeUnit.SECONDS).ignoring(NoSuchElementException.class, 
                        StaleElementReferenceException.class);
        configUpdate.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement configButton = m_Driver.findElement(By.cssSelector("button[id*='configurationButton']"));
                configButton.click();
                return true;
            }
        });
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("assetEditConfiguration")));
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        configTable = configDialog.findElement(By.cssSelector("tbody[id$='compositeConfigTable_data']"));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Activate on startup"), is(true));
        assertThat(ConfigurationHelper.getBooleanButtonValue(configTable, "Plugin overrides position"), is(true));
        assertThat(ConfigurationHelper.getInputBoxValue(configTable, "Device Power Toggle Name"), is("powerName"));
        assertThat(ConfigurationHelper.getSelectOneListBoxValue(configTable, "Example choice"), is("Option b"));
        configDialog = m_Driver.findElement(By.id("assetEditConfiguration"));
        cancelConfig = configDialog.findElement(By.cssSelector("button[id*='cancelConfig']"));
        cancelConfig.click();
    }
@ Test public void testAssetConfiguration ( ) throws InterruptedException { NavigationHelper . collapseSideBars ( m_Driver ) ; AssetHelper . createAsset ( m_Driver , "ExampleAsset" , "testExampleAsset" ) ; NavigationHelper . collapseSideBars ( m_Driver ) ; WebElement configButton = m_Driver . findElement ( By . cssSelector ( "button[id*='configurationButton']" ) ) ; configButton . click ( ) ; WebDriverWait wait = new WebDriverWait ( m_Driver , 30 ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . id ( "assetEditConfiguration" ) ) ) ; WebElement configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . id ( "assetEditConfiguration" ) ) ) ; WebElement configDialogHeader = configDialog . findElement ( By . cssSelector ( "span[class='ui-dialog-title']" ) ) ; assertThat ( configDialogHeader . getText ( ) , is ( "Asset Configuration" ) ) ; By selector = By . id ( "assetEditConfiguration" ) ; ConfigurationHelper . verifyDialogValues ( m_Driver , selector , "Activate on startup" , "Determines whether the asset should be activated during startup (Boolean)" ) ; ConfigurationHelper . verifyDialogValues ( m_Driver , selector , "Plugin overrides position" , "When this property is false, position is managed by the core for the asset instance. When true, " + "position will be managed by the plug-in. (Boolean)" ) ; ConfigurationHelper . verifyDialogValues ( m_Driver , selector , "Device Power Toggle Name" , "Name of device power toggle to use (String)" ) ; WebElement configTable = configDialog . findElement ( By . cssSelector ( "tbody[id$='compositeConfigTable_data']" ) ) ; assertThat ( ConfigurationHelper . getInputBoxValue ( configTable , "Device Power Toggle Name" ) , is ( "invalid, update this value!" ) ) ; ConfigurationHelper . updateValue ( configTable , "Activate on startup" , true ) ; ConfigurationHelper . updateValue ( configTable , "Plugin overrides position" , true ) ; ConfigurationHelper . updateValue ( configTable , "Device Power Toggle Name" , "powerName" ) ; ConfigurationHelper . updateValue ( configTable , "Example choice" , "Option b" ) ; configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; WebElement saveConfig = configDialog . findElement ( By . cssSelector ( "button[id*='saveConfig']" ) ) ; saveConfig . click ( ) ; wait . until ( ExpectedConditions . invisibilityOfElementLocated ( By . cssSelector ( "button[id*='saveConfig']" ) ) ) ; Thread . sleep ( 5000 ) ; m_Driver . findElement ( By . cssSelector ( "button[id*='configurationButton']" ) ) . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . id ( "assetEditConfiguration" ) ) ) ; configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; configTable = configDialog . findElement ( By . cssSelector ( "tbody[id$='compositeConfigTable_data']" ) ) ; assertThat ( ConfigurationHelper . getBooleanButtonValue ( configTable , "Activate on startup" ) , is ( true ) ) ; assertThat ( ConfigurationHelper . getBooleanButtonValue ( configTable , "Plugin overrides position" ) , is ( true ) ) ; assertThat ( ConfigurationHelper . getInputBoxValue ( configTable , "Device Power Toggle Name" ) , is ( "powerName" ) ) ; assertThat ( ConfigurationHelper . getSelectOneListBoxValue ( configTable , "Example choice" ) , is ( "Option b" ) ) ; ConfigurationHelper . updateValue ( configTable , "Activate on startup" , false ) ; ConfigurationHelper . updateValue ( configTable , "Plugin overrides position" , false ) ; ConfigurationHelper . updateValue ( configTable , "Device Power Toggle Name" , "failText" ) ; ConfigurationHelper . updateValue ( configTable , "Example choice" , "Option c" ) ; configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; WebElement cancelConfig = configDialog . findElement ( By . cssSelector ( "button[id*='cancelConfig']" ) ) ; cancelConfig . click ( ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . cssSelector ( "button[id*='configurationButton']" ) ) ) ; Wait < WebDriver > configUpdate = new FluentWait < WebDriver > ( m_Driver ) . withTimeout ( 30 , TimeUnit . SECONDS ) . pollingEvery ( 2 , TimeUnit . SECONDS ) . ignoring ( NoSuchElementException . class , StaleElementReferenceException . class ) ; configUpdate . until ( new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { WebElement configButton = m_Driver . findElement ( By . cssSelector ( "button[id*='configurationButton']" ) ) ; configButton . click ( ) ; return true ; } } ) ; wait . until ( ExpectedConditions . visibilityOfElementLocated ( By . id ( "assetEditConfiguration" ) ) ) ; configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; configTable = configDialog . findElement ( By . cssSelector ( "tbody[id$='compositeConfigTable_data']" ) ) ; assertThat ( ConfigurationHelper . getBooleanButtonValue ( configTable , "Activate on startup" ) , is ( true ) ) ; assertThat ( ConfigurationHelper . getBooleanButtonValue ( configTable , "Plugin overrides position" ) , is ( true ) ) ; assertThat ( ConfigurationHelper . getInputBoxValue ( configTable , "Device Power Toggle Name" ) , is ( "powerName" ) ) ; assertThat ( ConfigurationHelper . getSelectOneListBoxValue ( configTable , "Example choice" ) , is ( "Option b" ) ) ; configDialog = m_Driver . findElement ( By . id ( "assetEditConfiguration" ) ) ; cancelConfig = configDialog . findElement ( By . cssSelector ( "button[id*='cancelConfig']" ) ) ; cancelConfig . click ( ) ; }
Verify configuration dialog can correctly set configuration values for all properties for the asset.
Verify configuration dialog can correctly set configuration values for all properties for the asset .
//---bring up configuration dialog--- //---verify header is visible--- //---verify configuration values section is correct--- //verify values in dialog match expected values // verify default values // update config values //---save the configuration and verify that the values persist--- //verify dialog is closed //TODO TH-1265 problem with clicking this element right away //---bring up configuration dialog--- //---verify header is visible--- // verify value persisted before // set to new value //---verify cancellation of config does not persist new values--- //verify dialog is closed //used to bring up the configuration dialog again after saving configuration due to staleness //of elements caused from updates //---bring up configuration dialog--- //---verify header is visible--- // verify value persisted from before