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

File AnswerReplayerTest.java

 

Code metrics

0
13
1
1
64
30
1
0.08
13
1
1

Classes

Class Line # Actions
AnswerReplayerTest 40 13 0% 1 0
1.0100%
 

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.extension.job.history.internal;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    import org.junit.Test;
26    import org.xwiki.extension.job.history.ExtensionJobHistoryRecord;
27    import org.xwiki.extension.job.history.QuestionRecorder;
28    import org.xwiki.extension.job.history.ReplayJobStatus;
29    import org.xwiki.job.event.status.QuestionAskedEvent;
30   
31    import static org.junit.Assert.*;
32    import static org.mockito.Mockito.*;
33   
34    /**
35    * Unit tests for {@link AnswerReplayer}.
36    *
37    * @version $Id: 78cd3c5becb1095c7c5533cc2d56002e2b620153 $
38    * @since 7.1RC1
39    */
 
40    public class AnswerReplayerTest
41    {
 
42  1 toggle @Test
43    public void replayAnswerOK()
44    {
45  1 QuestionAskedEvent questionAskedEvent = new QuestionAskedEvent();
46   
47  1 String question = "What's up?";
48  1 QuestionRecorder<Object> questionRecorder = mock(QuestionRecorder.class);
49  1 when(questionRecorder.replay(question)).thenReturn(true);
50   
51  1 Map<String, QuestionRecorder<Object>> answers = new HashMap<>();
52  1 answers.put(question.getClass().getName(), questionRecorder);
53  1 ExtensionJobHistoryRecord currentRecord = new ExtensionJobHistoryRecord(null, null, answers, null, null);
54   
55  1 ReplayJobStatus replayJobStatus = mock(ReplayJobStatus.class);
56  1 when(replayJobStatus.getCurrentRecord()).thenReturn(currentRecord);
57  1 when(replayJobStatus.getQuestion()).thenReturn(question);
58   
59  1 AnswerReplayer answerReplayer = new AnswerReplayer();
60  1 answerReplayer.onEvent(questionAskedEvent, replayJobStatus, null);
61   
62  1 assertEquals(true, questionAskedEvent.isAnswered());
63    }
64    }