1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.test

File MockitoOldcoreRule.java

 

Coverage histogram

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

Code metrics

2
11
6
1
85
45
7
0.64
1.83
6
1.17

Classes

Class Line # Actions
MockitoOldcoreRule 34 11 0% 7 3
0.8421052784.2%
 

Contributing tests

No tests hitting this source file were found.

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 com.xpn.xwiki.test;
21   
22    import org.junit.rules.MethodRule;
23    import org.junit.runners.model.FrameworkMethod;
24    import org.junit.runners.model.Statement;
25    import org.xwiki.test.mockito.MockitoComponentManager;
26    import org.xwiki.test.mockito.MockitoComponentManagerRule;
27   
28    /**
29    * Test rule to initialize and manipulate various oldcore APIs.
30    *
31    * @version $Id: 508947c5ac2e78c79615d73ea25d6a3bdca2a94b $
32    * @since 5.2M1
33    */
 
34    public class MockitoOldcoreRule extends MockitoOldcore implements MethodRule
35    {
36    private final MethodRule parent;
37   
 
38  274 toggle public MockitoOldcoreRule()
39    {
40  274 this(new MockitoComponentManagerRule());
41    }
42   
 
43  325 toggle public MockitoOldcoreRule(MockitoComponentManagerRule componentManager)
44    {
45  325 this(componentManager, componentManager);
46    }
47   
48    /**
49    * @since 10.2
50    */
 
51  0 toggle public MockitoOldcoreRule(MockitoComponentManager componentManager)
52    {
53  0 this(componentManager, null);
54    }
55   
56    /**
57    * @since 10.2
58    */
 
59  325 toggle public MockitoOldcoreRule(MockitoComponentManager componentManager, MethodRule parent)
60    {
61  325 super(componentManager);
62   
63  325 this.parent = parent;
64    }
65   
 
66  325 toggle @Override
67    public Statement apply(final Statement base, final FrameworkMethod method, final Object target)
68    {
69  325 final Statement statement = new Statement()
70    {
 
71  325 toggle @Override
72    public void evaluate() throws Throwable
73    {
74  325 before(target.getClass());
75  325 try {
76  325 base.evaluate();
77    } finally {
78  325 after();
79    }
80    }
81    };
82   
83  325 return this.parent != null ? this.parent.apply(statement, method, target) : statement;
84    }
85    }