mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/helpers/observation/ObservationHelper.java
private static void verifyRelatedObsIndividualPanel(WebElement panel, 
            ExpectedObservation observation, RelationshipTypeEnum type)
    {
        List<RelatedObsStruct> list = observation.getRelatedObservation().getListForRelation(type);
        
        assertThat(list.size(), greaterThan(0));
        List<WebElement> listObsAsTables = panel.findElements(By.cssSelector("table[id$='relatedObsGrid']"));
        
        assertThat("Number of retrieved entries does not match the number of expected observation entries!", 
                listObsAsTables.size(), is(list.size()));
        
        List<RelatedObsStruct> expectedObs = observation.getRelatedObservation().getListForRelation(type);
        
        //iterate through the list of expected related observations
        for (RelatedObsStruct obsRelation : expectedObs)
        {
            boolean found = false;
            for (WebElement table : listObsAsTables)
            {
                //find a command link that is enabled
                List<WebElement> commandEnabledLink = table.findElements(By.cssSelector("span>a"));
                if (commandEnabledLink.size() > 0 )
                {
                    //obsRelation can have null observation (e.g. if observation is unknown/not found)
                    //which would not be for this case
                    if (obsRelation.getObservation() != null)
                    {
                        //get picture 
                        WebElement miniImage = table.findElement(By.cssSelector("img[id$='miniImage']"));
                        assertThat(miniImage, notNullValue());
                        String src = miniImage.getAttribute("src");
                        String pic = ImageHelper.getPictureOrIconName(src, ".png");
                        
                        if (obsRelation.getObservation().retrieveRelatedObservationImage().equals(pic))
                        {
                            String description = commandEnabledLink.get(0).getText();
                            
                            //if description is empty then UUID should be there
                            if (obsRelation.getDescription().isEmpty())
                            {
                                try
                                {
                                    UUID.fromString(description);
                                }
                                catch (IllegalArgumentException exception)
                                {
                                    fail(String.format("Description for an entry in relation type %s " 
                                            + "for observation with sensor id %s is incorrect", type, 
                                            observation.getSensorId()));
                                }
                                
                                found = true;
                                break;
                            }
                            else
                            {
                                //otherwise check string given is in the description found
                                if (description.contains(obsRelation.getDescription()))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    //couldn't find an enabled link so entry must be an unknown
                    List<WebElement> commandDisabledLink = table.findElements(By.cssSelector("span"));
                    if (commandDisabledLink.size() > 0)
                    {
                        if (obsRelation.getObservation() == null)
                        {
                            WebElement miniImage = table.findElement(By.cssSelector("img[id$='miniImage']"));
                            assertThat(miniImage, notNullValue());
                            String src = miniImage.getAttribute("src");
                            String pic = ImageHelper.getPictureOrIconName(src, ".png");
                            
                            if (pic.equals(ObservationConstants.IMG_UNKNOWN))
                            {
                                //verify warning icon
                                WebElement warningIcon = table.findElement(
                                        By.cssSelector("span[class='ui-icon ui-icon-alert']"));
                                assertThat(warningIcon, notNullValue());
                                
                                String description = commandDisabledLink.get(0).getText();
                                
                                //make sure description displayed is not empty; comparison should be 
                                //better but since UUID is not available a better comparison cannot be 
                                //made
                                if (obsRelation.getDescription().isEmpty() && !description.isEmpty())
                                {
                                    found = true;
                                    break;
                                }
                                else if (description.contains(obsRelation.getDescription()))
                                {
                                    found = true;
                                    break;
                                }
                            }
                            else
                            {
                                //image should be the unknown image. if it is anything else that is bad
                                fail(String.format("Improper image shown for unknown observation " 
                                        + "in relationship type %s", type));
                            }
                        }
                    }
                    else
                    {
                        //couldn't find any links so that is bad 
                        fail(String.format("Could not find command link for an entry of relationship type %s" 
                                + " for observation with sensor id [%s]",
                                type, observation.getSensorId()));
                    }
                }
            }
            
            //if I get through the list of displayed and not found then fail
            assertThat(String.format("Unable to find relation entry for" 
                    + " observation with sensor id [%s]", observation.getSensorId()), found, is(true));
        }
    }
/**
     * Function verifies a section of the related observation entries (Section is defined as one 
     * that is split by type. e.g. parent, child, peer are three separate sections).
     * @param panel
     *  the web element that holds the section
     * @param observation
     *  the observation which has the related observations
     * @param type
     *  the type of relationship to verify is present
     */
Function verifies a section of the related observation entries (Section is defined as one
that is split by type.
Function verifies a section of the related observation entries ( Section is defined as one that is split by type .
private static void verifyRelatedObsIndividualPanel(WebElement panel, 
            ExpectedObservation observation, RelationshipTypeEnum type)
    {
        List<RelatedObsStruct> list = observation.getRelatedObservation().getListForRelation(type);
        assertThat(list.size(), greaterThan(0));
        List<WebElement> listObsAsTables = panel.findElements(By.cssSelector("table[id$='relatedObsGrid']"));
        assertThat("Number of retrieved entries does not match the number of expected observation entries!", 
                listObsAsTables.size(), is(list.size()));
        List<RelatedObsStruct> expectedObs = observation.getRelatedObservation().getListForRelation(type);
        for (RelatedObsStruct obsRelation : expectedObs)
        {
            boolean found = false;
            for (WebElement table : listObsAsTables)
            {
                List<WebElement> commandEnabledLink = table.findElements(By.cssSelector("span>a"));
                if (commandEnabledLink.size() > 0 )
                {
                    if (obsRelation.getObservation() != null)
                    {
                        WebElement miniImage = table.findElement(By.cssSelector("img[id$='miniImage']"));
                        assertThat(miniImage, notNullValue());
                        String src = miniImage.getAttribute("src");
                        String pic = ImageHelper.getPictureOrIconName(src, ".png");
                        if (obsRelation.getObservation().retrieveRelatedObservationImage().equals(pic))
                        {
                            String description = commandEnabledLink.get(0).getText();
                            if (obsRelation.getDescription().isEmpty())
                            {
                                try
                                {
                                    UUID.fromString(description);
                                }
                                catch (IllegalArgumentException exception)
                                {
                                    fail(String.format("Description for an entry in relation type %s " 
                                            + "for observation with sensor id %s is incorrect", type, 
                                            observation.getSensorId()));
                                }
                                found = true;
                                break;
                            }
                            else
                            {
                                if (description.contains(obsRelation.getDescription()))
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    List<WebElement> commandDisabledLink = table.findElements(By.cssSelector("span"));
                    if (commandDisabledLink.size() > 0)
                    {
                        if (obsRelation.getObservation() == null)
                        {
                            WebElement miniImage = table.findElement(By.cssSelector("img[id$='miniImage']"));
                            assertThat(miniImage, notNullValue());
                            String src = miniImage.getAttribute("src");
                            String pic = ImageHelper.getPictureOrIconName(src, ".png");
                            if (pic.equals(ObservationConstants.IMG_UNKNOWN))
                            {
                                WebElement warningIcon = table.findElement(
                                        By.cssSelector("span[class='ui-icon ui-icon-alert']"));
                                assertThat(warningIcon, notNullValue());
                                String description = commandDisabledLink.get(0).getText();
                                if (obsRelation.getDescription().isEmpty() && !description.isEmpty())
                                {
                                    found = true;
                                    break;
                                }
                                else if (description.contains(obsRelation.getDescription()))
                                {
                                    found = true;
                                    break;
                                }
                            }
                            else
                            {
                                fail(String.format("Improper image shown for unknown observation " 
                                        + "in relationship type %s", type));
                            }
                        }
                    }
                    else
                    {
                        fail(String.format("Could not find command link for an entry of relationship type %s" 
                                + " for observation with sensor id [%s]",
                                type, observation.getSensorId()));
                    }
                }
            }
            assertThat(String.format("Unable to find relation entry for" 
                    + " observation with sensor id [%s]", observation.getSensorId()), found, is(true));
        }
    }
private static void verifyRelatedObsIndividualPanel ( WebElement panel , ExpectedObservation observation , RelationshipTypeEnum type ) { List < RelatedObsStruct > list = observation . getRelatedObservation ( ) . getListForRelation ( type ) ; assertThat ( list . size ( ) , greaterThan ( 0 ) ) ; List < WebElement > listObsAsTables = panel . findElements ( By . cssSelector ( "table[id$='relatedObsGrid']" ) ) ; assertThat ( "Number of retrieved entries does not match the number of expected observation entries!" , listObsAsTables . size ( ) , is ( list . size ( ) ) ) ; List < RelatedObsStruct > expectedObs = observation . getRelatedObservation ( ) . getListForRelation ( type ) ; for ( RelatedObsStruct obsRelation : expectedObs ) { boolean found = false ; for ( WebElement table : listObsAsTables ) { List < WebElement > commandEnabledLink = table . findElements ( By . cssSelector ( "span>a" ) ) ; if ( commandEnabledLink . size ( ) > 0 ) { if ( obsRelation . getObservation ( ) != null ) { WebElement miniImage = table . findElement ( By . cssSelector ( "img[id$='miniImage']" ) ) ; assertThat ( miniImage , notNullValue ( ) ) ; String src = miniImage . getAttribute ( "src" ) ; String pic = ImageHelper . getPictureOrIconName ( src , ".png" ) ; if ( obsRelation . getObservation ( ) . retrieveRelatedObservationImage ( ) . equals ( pic ) ) { String description = commandEnabledLink . get ( 0 ) . getText ( ) ; if ( obsRelation . getDescription ( ) . isEmpty ( ) ) { try { UUID . fromString ( description ) ; } catch ( IllegalArgumentException exception ) { fail ( String . format ( "Description for an entry in relation type %s " + "for observation with sensor id %s is incorrect" , type , observation . getSensorId ( ) ) ) ; } found = true ; break ; } else { if ( description . contains ( obsRelation . getDescription ( ) ) ) { found = true ; break ; } } } } } else { List < WebElement > commandDisabledLink = table . findElements ( By . cssSelector ( "span" ) ) ; if ( commandDisabledLink . size ( ) > 0 ) { if ( obsRelation . getObservation ( ) == null ) { WebElement miniImage = table . findElement ( By . cssSelector ( "img[id$='miniImage']" ) ) ; assertThat ( miniImage , notNullValue ( ) ) ; String src = miniImage . getAttribute ( "src" ) ; String pic = ImageHelper . getPictureOrIconName ( src , ".png" ) ; if ( pic . equals ( ObservationConstants . IMG_UNKNOWN ) ) { WebElement warningIcon = table . findElement ( By . cssSelector ( "span[class='ui-icon ui-icon-alert']" ) ) ; assertThat ( warningIcon , notNullValue ( ) ) ; String description = commandDisabledLink . get ( 0 ) . getText ( ) ; if ( obsRelation . getDescription ( ) . isEmpty ( ) && ! description . isEmpty ( ) ) { found = true ; break ; } else if ( description . contains ( obsRelation . getDescription ( ) ) ) { found = true ; break ; } } else { fail ( String . format ( "Improper image shown for unknown observation " + "in relationship type %s" , type ) ) ; } } } else { fail ( String . format ( "Could not find command link for an entry of relationship type %s" + " for observation with sensor id [%s]" , type , observation . getSensorId ( ) ) ) ; } } } assertThat ( String . format ( "Unable to find relation entry for" + " observation with sensor id [%s]" , observation . getSensorId ( ) ) , found , is ( true ) ) ; } }
Function verifies a section of the related observation entries (Section is defined as one
 that is split by type.
Function verifies a section of the related observation entries ( Section is defined as one that is split by type .
//iterate through the list of expected related observations //find a command link that is enabled //obsRelation can have null observation (e.g. if observation is unknown/not found) //which would not be for this case //get picture  //if description is empty then UUID should be there //otherwise check string given is in the description found //couldn't find an enabled link so entry must be an unknown //verify warning icon //make sure description displayed is not empty; comparison should be  //better but since UUID is not available a better comparison cannot be  //made //image should be the unknown image. if it is anything else that is bad //couldn't find any links so that is bad  //if I get through the list of displayed and not found then fail