mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/webapp/comms/TestAddCommsDlg.java
@Test
    public void testRefreshTypes() throws InterruptedException
    {
        // uninstall ccomm bundle and open up add comms dialog
        BundleManagerUtil.uninstallBundle(m_Driver, "example.ccomm.main",
                NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsGeneralHelper.setBundleInstalled(false);
        WebElement addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        addCommsButton.click();

        // verify that ccomm layer types still exist even after bundle uninstalled
        WebElement layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Link Layer",
                "example.ccomms.ExampleLinkLayer");
        assertThat(layer, is(notNullValue()));
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.EchoTransport");

        // If there are more then 3 in the list, select next page, then check again
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.EchoTransport");
        }

        assertThat(layer, is(notNullValue()));
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.DirectTransport");

        // If there are more then 3 in the list, select next page, then check again
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                    "example.ccomms.DirectTransport");
            if(layer == null)
            {
                CommsAddDialogHelper.selectBackCommsLayerPage(m_Driver);
                layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                        "example.ccomms.DirectTransport");
            }
        }
        assertThat(layer, is(notNullValue()));

        // refresh the layer types
        WebElement refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshCommsTypes']"));
        refreshTypesButton.click();

        wait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("tbody[id$='transportData_data']>tr>td>div")));
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("tbody[id$='linkData_data']>tr>td>div")));

        Wait<WebDriver> fwait = new FluentWait<WebDriver>(m_Driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(1,
                TimeUnit.SECONDS).ignoring(StaleElementReferenceException.class, NoSuchElementException.class);

        // assert that old transport layer types do not exist since example ccomm bundle was deleted
        // Use fluent wait to check first one since the refresh types push update might not be finished.
        fwait.until(new ExpectedCondition<Boolean>()
        {
            @Override
            public Boolean apply(WebDriver driver)
            {
                WebElement layer = null;
                try
                {
                    layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                            "example.ccomms.EchoTransport");
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                assertThat(layer, is(nullValue()));
                return true;
            }
        });

        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.DirectTransport");
        assertThat(layer, is(nullValue()));

        // open link layer tab and assert that old link layer types do not exist since example ccomm bundle was deleted
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Link Layer", "example.ccomms.ExampleLinkLayer");
        assertThat(layer, is(nullValue()));

        // re-install bundle
        BundleManagerUtil.installBundle(m_Driver, ResourceLocatorUtil.getExampleCustomCommPluginFile(),
                NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsGeneralHelper.setBundleInstalled(true);

        // open up add comms dialog and refresh the types again so they are available for the next test
        addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        wait.until(ExpectedConditions.visibilityOf(addCommsButton));
        addCommsButton.click();

        refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshCommsTypes']"));
        wait.until(ExpectedConditions.visibilityOf(refreshTypesButton));
        refreshTypesButton.click();

        GeneralHelper.sleepWithText(5, "Waiting for AJAX update of the dialog as it has been refreshed");

        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[id*='cancelStackButton']")));

        GeneralHelper.safeClickBySelector(By.cssSelector("button[id*='cancelStackButton']"));
    }
/**
     * Verify types of usable layers are successfully refreshed after removal of a bundle.
     */
Verify types of usable layers are successfully refreshed after removal of a bundle.
Verify types of usable layers are successfully refreshed after removal of a bundle .
@Test
    public void testRefreshTypes() throws InterruptedException
    {
        BundleManagerUtil.uninstallBundle(m_Driver, "example.ccomm.main",
                NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsGeneralHelper.setBundleInstalled(false);
        WebElement addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        addCommsButton.click();
        WebElement layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Link Layer",
                "example.ccomms.ExampleLinkLayer");
        assertThat(layer, is(notNullValue()));
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.EchoTransport");
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.EchoTransport");
        }
        assertThat(layer, is(notNullValue()));
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.DirectTransport");
        if (layer == null)
        {
            CommsAddDialogHelper.selectNextCommsLayerPage(m_Driver);
            layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                    "example.ccomms.DirectTransport");
            if(layer == null)
            {
                CommsAddDialogHelper.selectBackCommsLayerPage(m_Driver);
                layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                        "example.ccomms.DirectTransport");
            }
        }
        assertThat(layer, is(notNullValue()));
        WebElement refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshCommsTypes']"));
        refreshTypesButton.click();
        wait.until(ExpectedConditions.presenceOfElementLocated(
                By.cssSelector("tbody[id$='transportData_data']>tr>td>div")));
        wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("tbody[id$='linkData_data']>tr>td>div")));
        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(WebDriver driver)
            {
                WebElement layer = null;
                try
                {
                    layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type",
                            "example.ccomms.EchoTransport");
                }
                catch (InterruptedException e)
                {
                    e.printStackTrace();
                }
                assertThat(layer, is(nullValue()));
                return true;
            }
        });
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Transport Type", "example.ccomms.DirectTransport");
        assertThat(layer, is(nullValue()));
        layer = CommsAddDialogHelper.layerSelectHelper(m_Driver, "Link Layer", "example.ccomms.ExampleLinkLayer");
        assertThat(layer, is(nullValue()));
        BundleManagerUtil.installBundle(m_Driver, ResourceLocatorUtil.getExampleCustomCommPluginFile(),
                NavigationButtonNameConstants.NAVBUT_PROP_COMMS);
        CommsGeneralHelper.setBundleInstalled(true);
        addCommsButton = m_Driver.findElement(By.cssSelector("button[id*='addCommsButton']"));
        wait.until(ExpectedConditions.visibilityOf(addCommsButton));
        addCommsButton.click();
        refreshTypesButton = m_Driver.findElement(By.cssSelector("button[id*='refreshCommsTypes']"));
        wait.until(ExpectedConditions.visibilityOf(refreshTypesButton));
        refreshTypesButton.click();
        GeneralHelper.sleepWithText(5, "Waiting for AJAX update of the dialog as it has been refreshed");
        wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("button[id*='cancelStackButton']")));
        GeneralHelper.safeClickBySelector(By.cssSelector("button[id*='cancelStackButton']"));
    }
@ Test public void testRefreshTypes ( ) throws InterruptedException { BundleManagerUtil . uninstallBundle ( m_Driver , "example.ccomm.main" , NavigationButtonNameConstants . NAVBUT_PROP_COMMS ) ; CommsGeneralHelper . setBundleInstalled ( false ) ; WebElement addCommsButton = m_Driver . findElement ( By . cssSelector ( "button[id*='addCommsButton']" ) ) ; addCommsButton . click ( ) ; WebElement layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Link Layer" , "example.ccomms.ExampleLinkLayer" ) ; assertThat ( layer , is ( notNullValue ( ) ) ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.EchoTransport" ) ; if ( layer == null ) { CommsAddDialogHelper . selectNextCommsLayerPage ( m_Driver ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.EchoTransport" ) ; } assertThat ( layer , is ( notNullValue ( ) ) ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; if ( layer == null ) { CommsAddDialogHelper . selectNextCommsLayerPage ( m_Driver ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; if ( layer == null ) { CommsAddDialogHelper . selectBackCommsLayerPage ( m_Driver ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; } } assertThat ( layer , is ( notNullValue ( ) ) ) ; WebElement refreshTypesButton = m_Driver . findElement ( By . cssSelector ( "button[id*='refreshCommsTypes']" ) ) ; refreshTypesButton . click ( ) ; wait . until ( ExpectedConditions . presenceOfElementLocated ( By . cssSelector ( "tbody[id$='transportData_data']>tr>td>div" ) ) ) ; wait . until ( ExpectedConditions . presenceOfElementLocated ( By . cssSelector ( "tbody[id$='linkData_data']>tr>td>div" ) ) ) ; 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 ( WebDriver driver ) { WebElement layer = null ; try { layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.EchoTransport" ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } assertThat ( layer , is ( nullValue ( ) ) ) ; return true ; } } ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Transport Type" , "example.ccomms.DirectTransport" ) ; assertThat ( layer , is ( nullValue ( ) ) ) ; layer = CommsAddDialogHelper . layerSelectHelper ( m_Driver , "Link Layer" , "example.ccomms.ExampleLinkLayer" ) ; assertThat ( layer , is ( nullValue ( ) ) ) ; BundleManagerUtil . installBundle ( m_Driver , ResourceLocatorUtil . getExampleCustomCommPluginFile ( ) , NavigationButtonNameConstants . NAVBUT_PROP_COMMS ) ; CommsGeneralHelper . setBundleInstalled ( true ) ; addCommsButton = m_Driver . findElement ( By . cssSelector ( "button[id*='addCommsButton']" ) ) ; wait . until ( ExpectedConditions . visibilityOf ( addCommsButton ) ) ; addCommsButton . click ( ) ; refreshTypesButton = m_Driver . findElement ( By . cssSelector ( "button[id*='refreshCommsTypes']" ) ) ; wait . until ( ExpectedConditions . visibilityOf ( refreshTypesButton ) ) ; refreshTypesButton . click ( ) ; GeneralHelper . sleepWithText ( 5 , "Waiting for AJAX update of the dialog as it has been refreshed" ) ; wait . until ( ExpectedConditions . elementToBeClickable ( By . cssSelector ( "button[id*='cancelStackButton']" ) ) ) ; GeneralHelper . safeClickBySelector ( By . cssSelector ( "button[id*='cancelStackButton']" ) ) ; }
Verify types of usable layers are successfully refreshed after removal of a bundle.
Verify types of usable layers are successfully refreshed after removal of a bundle .
// uninstall ccomm bundle and open up add comms dialog // verify that ccomm layer types still exist even after bundle uninstalled // If there are more then 3 in the list, select next page, then check again // If there are more then 3 in the list, select next page, then check again // refresh the layer types // assert that old transport layer types do not exist since example ccomm bundle was deleted // Use fluent wait to check first one since the refresh types push update might not be finished. // open link layer tab and assert that old link layer types do not exist since example ccomm bundle was deleted // re-install bundle // open up add comms dialog and refresh the types again so they are available for the next test