1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.refactoring.internal.job

File AbstractEntityJobTest.java

 

Coverage histogram

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

Code metrics

0
8
2
1
66
33
2
0.25
4
2
1

Classes

Class Line # Actions
AbstractEntityJobTest 40 8 0% 2 0
1.0100%
 

Contributing tests

This file is covered by 33 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.refactoring.internal.job;
21   
22    import org.junit.Before;
23    import org.xwiki.job.Job;
24    import org.xwiki.model.EntityType;
25    import org.xwiki.model.reference.EntityReference;
26    import org.xwiki.model.reference.EntityReferenceProvider;
27    import org.xwiki.refactoring.internal.ModelBridge;
28    import org.xwiki.refactoring.job.EntityRequest;
29    import org.xwiki.security.authorization.AuthorizationManager;
30    import org.xwiki.test.mockito.MockitoComponentMockingRule;
31   
32    import static org.mockito.Mockito.*;
33   
34    /**
35    * Base class for writing unit tests for jobs extending {@link AbstractEntityJob}.
36    *
37    * @version $Id: ba7d09fb4429714570e6d9af9b4ebb81ac2c4b37 $
38    * @since 7.4M2
39    */
 
40    public abstract class AbstractEntityJobTest
41    {
42    protected AuthorizationManager authorization;
43   
44    protected ModelBridge modelBridge;
45   
 
46  33 toggle @Before
47    public void configure() throws Exception
48    {
49  33 this.authorization = getMocker().getInstance(AuthorizationManager.class);
50  33 this.modelBridge = getMocker().getInstance(ModelBridge.class);
51   
52  33 EntityReferenceProvider defaultEntityReferenceProvider = getMocker().getInstance(EntityReferenceProvider.class);
53  33 when(defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(
54    new EntityReference("WebHome", EntityType.DOCUMENT, null));
55    }
56   
57    protected abstract MockitoComponentMockingRule<Job> getMocker();
58   
 
59  35 toggle protected Job run(EntityRequest request) throws Exception
60    {
61  35 Job job = getMocker().getComponentUnderTest();
62  35 job.initialize(request);
63  35 job.run();
64  35 return job;
65    }
66    }