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

File TestBasicGroupedJob.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
74% of files have more coverage

Code metrics

0
27
23
1
203
140
23
0.85
1.17
23
1

Classes

Class Line # Actions
TestBasicGroupedJob 36 27 0% 23 28
0.4444%
 

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.job.test;
21   
22    import java.util.Date;
23    import java.util.List;
24    import java.util.concurrent.TimeUnit;
25    import java.util.concurrent.locks.ReentrantLock;
26   
27    import org.xwiki.job.GroupedJob;
28    import org.xwiki.job.JobGroupPath;
29    import org.xwiki.job.Request;
30    import org.xwiki.job.event.status.JobProgress;
31    import org.xwiki.job.event.status.JobStatus;
32    import org.xwiki.logging.LogLevel;
33    import org.xwiki.logging.LogQueue;
34    import org.xwiki.logging.event.LogEvent;
35   
 
36    public class TestBasicGroupedJob implements GroupedJob, JobStatus
37    {
38    private final transient ReentrantLock lock = new ReentrantLock();
39   
40    private Request request;
41   
42    private JobGroupPath jobGroupPath;
43   
44    private State state;
45   
46    private Throwable error;
47   
48    private LogQueue logQueue = new LogQueue();
49   
50    private Thread thread;
51   
 
52  4 toggle public TestBasicGroupedJob(JobGroupPath jobGroupPath, Request request)
53    {
54  4 this.jobGroupPath = jobGroupPath;
55  4 this.request = request;
56    }
57   
 
58  0 toggle @Override
59    public String getType()
60    {
61  0 return "test";
62    }
63   
 
64  12 toggle @Override
65    public JobStatus getStatus()
66    {
67  12 return this;
68    }
69   
 
70  12 toggle @Override
71    public Request getRequest()
72    {
73  12 return this.request;
74    }
75   
 
76  0 toggle @Override
77    @Deprecated
78    public void start(Request request)
79    {
80  0 initialize(request);
81  0 run();
82    }
83   
 
84  0 toggle @Override
85    public void initialize(Request request)
86    {
87  0 this.request = request;
88    }
89   
 
90  0 toggle @Override
91    public void join() throws InterruptedException
92    {
93    // Not implemented
94    }
95   
 
96  0 toggle @Override
97    public boolean join(long time, TimeUnit unit) throws InterruptedException
98    {
99    // Not implemented
100   
101  0 return false;
102    }
103   
 
104  4 toggle @Override
105    public void run()
106    {
107  4 this.state = State.RUNNING;
108   
109  4 this.thread = Thread.currentThread();
110   
111  4 this.state = State.WAITING;
112  4 lock.lock();
113  4 this.state = State.RUNNING;
114   
115  4 this.state = State.FINISHED;
116    }
117   
 
118  4 toggle @Override
119    public JobGroupPath getGroupPath()
120    {
121  4 return this.jobGroupPath;
122    }
123   
 
124  12 toggle @Override
125    public State getState()
126    {
127  12 return this.state;
128    }
129   
 
130  0 toggle @Override
131    public Throwable getError()
132    {
133  0 return this.error;
134    }
135   
 
136  0 toggle @Override
137    public LogQueue getLog()
138    {
139  0 return this.logQueue;
140    }
141   
 
142  0 toggle @Override
143    public JobProgress getProgress()
144    {
145    // Not implemented
146  0 return null;
147    }
148   
 
149  0 toggle @Override
150    public void ask(Object question) throws InterruptedException
151    {
152    // Not implemented
153    }
154   
 
155  0 toggle @Override
156    public Object getQuestion()
157    {
158    // Not implemented
159  0 return null;
160    }
161   
 
162  0 toggle @Override
163    public void answered()
164    {
165    // Not implemented
166    }
167   
 
168  0 toggle @Override
169    public Date getStartDate()
170    {
171    // Not implemented
172  0 return null;
173    }
174   
 
175  0 toggle @Override
176    public Date getEndDate()
177    {
178    // Not implemented
179  0 return null;
180    }
181   
 
182  0 toggle @Override
183    @Deprecated
184    public List<LogEvent> getLog(LogLevel level)
185    {
186  0 return this.logQueue.getLogs(level);
187    }
188   
 
189  0 toggle public Thread getThread()
190    {
191  0 return this.thread;
192    }
193   
 
194  4 toggle public void lock()
195    {
196  4 this.lock.lock();
197    }
198   
 
199  4 toggle public void unlock()
200    {
201  4 this.lock.unlock();
202    }
203    }