1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.blog.test.po

File BlogPostViewPage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
9
5
1
114
49
5
0.56
1.8
5
1

Classes

Class Line # Actions
BlogPostViewPage 37 9 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.blog.test.po;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.apache.commons.codec.binary.StringUtils;
26    import org.openqa.selenium.By;
27    import org.openqa.selenium.WebElement;
28    import org.openqa.selenium.support.FindBy;
29    import org.xwiki.test.ui.po.ViewPage;
30   
31    /**
32    * The page that displays a blog post.
33    *
34    * @version $Id: 498ebe116f685aa7ab75458033803334350e4792 $
35    * @since 4.2M1
36    */
 
37    public class BlogPostViewPage extends ViewPage
38    {
39    /**
40    * The blog post content.
41    */
42    @FindBy(className = "hentry")
43    private WebElement entry;
44   
45    /**
46    * A warning message.
47    */
48    @FindBy(className = "warningmessage")
49    private WebElement warningMessage;
50   
51    /**
52    * The blog post content.
53    */
54    @FindBy(className = "entry-content")
55    private WebElement content;
56   
57    /**
58    * The blog post footer.
59    */
60    @FindBy(className = "entry-footer")
61    private WebElement footer;
62    /**
63    * The edit blog post icon.
64    */
65    @FindBy(xpath = "//*[@class = 'blog-entry-toolbox']//a[contains(@title, 'Edit')]")
66    private WebElement editIcon;
67   
 
68  2 toggle @Override
69    public String getContent()
70    {
71  2 return content.getText();
72    }
73   
74    /**
75    * @return the list of categories the displayed blog post is part of
76    */
 
77  2 toggle public List<String> getCategories()
78    {
79  2 List<String> categories = new ArrayList<String>();
80  2 for (WebElement categoryLink : footer.findElements(By.xpath("//a[@rel = 'tag']"))) {
81  3 categories.add(categoryLink.getText());
82    }
83  2 return categories;
84    }
85   
86    /**
87    * @return {@code true} if the displayed blog post is published, {@code false} otherwise
88    */
 
89  2 toggle public boolean isPublished()
90    {
91  2 return !getDriver().hasElementWithoutWaiting(entry, By.className("warningmessage"))
92    || !StringUtils.equals("This blog post is not published yet.", warningMessage.getText());
93    }
94   
95    /**
96    * @return {@code true} if the displayed blog post is hidden from the rest of the users, {@code false} otherwise
97    */
 
98  1 toggle public boolean isHidden()
99    {
100  1 return getDriver().hasElementWithoutWaiting(entry, By.className("warningmessage"))
101    && StringUtils.equals("This blog post is hidden.", warningMessage.getText());
102    }
103   
104    /**
105    * Clicks on the edit blog post icon.
106    *
107    * @return the "Inline form" edit page used for editing the blog post
108    */
 
109  1 toggle public BlogPostInlinePage clickEditBlogPostIcon()
110    {
111  1 editIcon.click();
112  1 return new BlogPostInlinePage();
113    }
114    }