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

File InvitationFooterElement.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

6
15
5
1
85
51
8
0.53
3
5
1.6

Classes

Class Line # Actions
InvitationFooterElement 34 15 0% 8 4
0.8461538684.6%
 

Contributing tests

This file is covered by 5 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 org.openqa.selenium.By;
23    import org.openqa.selenium.WebDriverException;
24    import org.openqa.selenium.WebElement;
25    import org.openqa.selenium.support.FindBy;
26    import org.xwiki.test.ui.po.BaseElement;
27   
28    /**
29    * Represents the actions possible on the invitation sender page.
30    *
31    * @version $Id: 0ad76b178a3bde074e7384591673c164132f72fc $
32    * @since 4.2M1
33    */
 
34    public class InvitationFooterElement extends BaseElement
35    {
36    @FindBy(id = "invitation-footer")
37    private WebElement footer;
38   
39    @FindBy(xpath = "//div[@id='invitation-footer']//a[@href='/xwiki/bin/view/Invitation/InvitationMemberActions?inspect=all']")
40    private WebElement inspectAll;
41   
42    @FindBy(xpath = "//div[@id='invitation-footer']//a[@href='/xwiki/bin/view/Invitation/InvitationMemberActions?inspect=allAsAdmin']")
43    private WebElement inspectAllAsAdmin;
44   
 
45  1 toggle public boolean isAdmin()
46    {
47  1 return !getDriver().findElementsWithoutWaiting(this.footer, By.id("HAdministrativeTools")).isEmpty();
48    }
49   
 
50  2 toggle public InspectInvitationsPage inspectMyInvitations()
51    {
52  2 this.inspectAll.click();
53  2 return new InspectInvitationsPage.AsUser();
54    }
55   
 
56  1 toggle public InspectInvitationsPage inspectAllInvitations()
57    {
58  1 if (!isAdmin()) {
59  0 throw new WebDriverException("Inspection as admin impossible because user is not admin.");
60    }
61  1 this.inspectAllAsAdmin.click();
62  1 return new InspectInvitationsPage.AsAdmin();
63    }
64   
 
65  4 toggle public int myPendingInvitations()
66    {
67  4 if (getDriver().findElementsWithoutWaiting(this.footer, By.id("my-pending-invitations")).size() == 0)
68    {
69  0 return 0;
70    }
71  4 String message = getDriver().findElementsWithoutWaiting(this.footer,
72    By.id("my-pending-invitations")).get(0).getText().trim();
73  4 return Integer.parseInt(message.substring(0, message.indexOf(" pending")));
74    }
75   
 
76  2 toggle public int spamReports()
77    {
78  2 if (getDriver().findElementsWithoutWaiting(this.footer, By.id("spam-reports")).size() == 0) {
79  1 return 0;
80    }
81  1 String message = getDriver().findElementsWithoutWaiting(this.footer,
82    By.id("spam-reports")).get(0).getText().trim();
83  1 return Integer.parseInt(message.substring(0, message.indexOf(" reported as spam")));
84    }
85    }