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

File InspectInvitationsPage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

6
35
15
6
196
138
18
0.51
2.33
2.5
1.2

Classes

Class Line # Actions
InspectInvitationsPage 38 17 0% 7 5
0.807692380.8%
InspectInvitationsPage.OneMessage 89 0 - 0 0
-1.0 -
InspectInvitationsPage.AsAdmin 103 2 0% 1 0
1.0100%
InspectInvitationsPage.AsAdmin.OneMessage 112 9 0% 5 8
0.4666666746.7%
InspectInvitationsPage.AsUser 153 2 0% 1 0
1.0100%
InspectInvitationsPage.AsUser.OneMessage 165 5 0% 4 4
0.555555655.6%
 

Contributing tests

This file is covered by 3 tests. .

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.invitation.test.po;
21   
22    import java.util.List;
23    import java.util.ArrayList;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.support.FindBy;
27    import org.openqa.selenium.WebElement;
28    import org.openqa.selenium.WebDriverException;
29    import org.xwiki.test.ui.po.BasePage;
30    import org.xwiki.test.ui.po.TableElement;
31   
32    /**
33    * Represents the actions possible when inspecting invitations.
34    *
35    * @version $Id: e4e17b1e1f231ab783548b4ac03dec3e76beb839 $
36    * @since 4.2M1
37    */
 
38    public abstract class InspectInvitationsPage extends BasePage
39    {
40    private InvitationFooterElement footer = new InvitationFooterElement();
41   
42    @FindBy(tagName = "table")
43    private WebElement tableWebEl;
44   
 
45  7 toggle public TableElement getTable()
46    {
47  7 return new TableElement(tableWebEl);
48    }
49   
 
50  0 toggle public InvitationFooterElement getFooter() {
51  0 return footer;
52    }
53   
54    /** If there is a message box telling the status and memo the content is returned. */
 
55  3 toggle public String getStatusAndMemo()
56    {
57  3 List<WebElement> elements = getDriver().findElementsWithoutWaiting(By.id("message-status-and-memo"));
58  3 if (elements.size() > 0) {
59  3 return elements.get(0).getText();
60    }
61  0 return null;
62    }
63   
 
64  3 toggle public OneMessage getMessageWhere(String columnName, String value)
65    {
66  3 List<String> columnEntries = new ArrayList<String>();
67  3 List<WebElement> column = getTable().getColumn(columnName);
68  3 for (WebElement cell : column) {
69  6 if (cell.getText().equals(value)) {
70    // Get the Subject element in the same row and look inside for a link.
71  3 WebElement link = getDriver().findElementsWithoutWaiting(
72    getTable().getColumn("Subject").get(column.indexOf(cell)), By.tagName("a")).get(0);
73  3 link.click();
74  3 return null;
75    }
76  3 columnEntries.add(cell.getText());
77    }
78  0 throw new WebDriverException("Could not find message with " + column + " equal to "
79    + value + "\nIn columbn with entries: " + columnEntries.toString());
80    }
81   
82    /** Should only be made available to OneMessage implementations. */
 
83  1 toggle protected TableElement clickMessageHistory()
84    {
85  1 getTable().getColumn("Message History").get(1).findElements(By.tagName("a")).get(0).click();
86  1 return new TableElement(getDriver().findElement(By.id("message-history-table")).findElement(By.tagName("table")));
87    }
88   
 
89    public static interface OneMessage
90    {
91    public InvitationMessageDisplayElement getMessage();
92   
93    /** Returns the message telling the user that they successfully set the status to not spam */
94    public String notSpam(String message);
95   
96    public InvitationActionConfirmationElement cancel();
97   
98    public String getStatusAndMemo();
99   
100    public TableElement clickMessageHistory();
101    }
102   
 
103    public static class AsAdmin extends InspectInvitationsPage
104    {
 
105  1 toggle @Override
106    public OneMessage getMessageWhere(String column, String value)
107    {
108  1 super.getMessageWhere(column, value);
109  1 return this.new OneMessage();
110    }
111   
 
112    public class OneMessage extends AsAdmin implements InspectInvitationsPage.OneMessage
113    {
114    @FindBy(id = "invitation-displaymessage")
115    private WebElement preview;
116   
117    @FindBy(name = "doAction_notSpam")
118    private WebElement notSpamButton;
119   
 
120  0 toggle @Override
121    public InvitationMessageDisplayElement getMessage()
122    {
123  0 return new InvitationMessageDisplayElement(preview);
124    }
125   
 
126  0 toggle @Override
127    public TableElement clickMessageHistory()
128    {
129  0 return super.clickMessageHistory();
130    }
131   
 
132  0 toggle @Override
133    public InvitationActionConfirmationElement cancel()
134    {
135  0 throw new WebDriverException("Invitation cannot be canceled as an admin");
136    }
137   
 
138  1 toggle @Override
139    public String notSpam(String message)
140    {
141  1 notSpamButton.click();
142  1 InvitationActionConfirmationElement confirm = new InvitationActionConfirmationElement();
143    // We can't go forward unless we are on the right form.
144  1 if (!confirm.getLabel().equalsIgnoreCase("Synopsis of findings and/or action taken")) {
145  0 throw new WebDriverException("Not on 'not spam' confirm page, message says: " + confirm.getLabel());
146    }
147  1 confirm.setMemo(message);
148  1 return confirm.confirm();
149    }
150    }
151    }
152   
 
153    public static class AsUser extends InspectInvitationsPage
154    {
155    @FindBy(name = "doAction_cancel")
156    protected WebElement cancelButton;
157   
 
158  2 toggle @Override
159    public OneMessage getMessageWhere(String column, String value)
160    {
161  2 super.getMessageWhere(column, value);
162  2 return this.new OneMessage();
163    }
164   
 
165    public class OneMessage extends AsUser implements InspectInvitationsPage.OneMessage
166    {
167    @FindBy(id = "invitation-displaymessage")
168    private WebElement preview;
169   
 
170  0 toggle @Override
171    public InvitationMessageDisplayElement getMessage()
172    {
173  0 return new InvitationMessageDisplayElement(preview);
174    }
175   
 
176  1 toggle @Override
177    public TableElement clickMessageHistory()
178    {
179  1 return super.clickMessageHistory();
180    }
181   
 
182  1 toggle @Override
183    public InvitationActionConfirmationElement cancel()
184    {
185  1 cancelButton.click();
186  1 return new InvitationActionConfirmationElement();
187    }
188   
 
189  0 toggle @Override
190    public String notSpam(String message)
191    {
192  0 throw new WebDriverException("Function only possible for admin.");
193    }
194    }
195    }
196    }