Skip to content

Commit

Permalink
Fix most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed May 27, 2019
1 parent e19691c commit 052e859
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public PluginImpl() {
* {@inheritDoc}
*/
@Override
protected XmlFile getConfigFile() {
public XmlFile getConfigFile() {
return new XmlFile(
XSTREAM,
new File(Jenkins.getInstance().getRootDir(), "build-failure-analyzer.xml")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.sonyericsson.jenkins.plugins.bfa.statistics.Statistics;
import com.sonyericsson.jenkins.plugins.bfa.statistics.Statistics.UpstreamCause;
import com.sonyericsson.jenkins.plugins.bfa.utils.ObjectCountPair;
import jenkins.model.Jenkins;
import org.jfree.data.time.Day;
import org.jfree.data.time.Hour;
import org.jfree.data.time.TimePeriod;
Expand All @@ -43,6 +44,7 @@
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -61,6 +63,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.when;

Expand All @@ -71,7 +74,7 @@
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(PluginImpl.class)
@PrepareForTest(value = {PluginImpl.class, Jenkins.class})
@PowerMockIgnore("javax.management.*") //Solves PowerMock issue 277
public class EmbeddedMongoStatisticsTest extends EmbeddedMongoTest {
// CS IGNORE MagicNumber FOR NEXT 600 LINES. REASON: Test data.
Expand Down Expand Up @@ -110,6 +113,11 @@ public void setUp() throws IOException {
filter1 = new GraphFilterBuilder();
filter2 = new GraphFilterBuilder();

Jenkins mockJenkins = mock(Jenkins.class);
mockStatic(Jenkins.class);
when(Jenkins.getInstance()).thenReturn(mockJenkins);
when(mockJenkins.getRootDir()).thenReturn(new File(""));

PluginImpl plugin = new PluginImpl();
mockStatic(PluginImpl.class);
when(PluginImpl.getInstance()).thenReturn(plugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ knowledgeBase:

port: 27017
successfulLogging: false
userName: bfa
userName: "bfa"
maxLogSize: 10
noCausesMessage: "No problems were identified. If you know why this problem occurred,\
\ please add a suitable Cause for it."
Expand Down

0 comments on commit 052e859

Please sign in to comment.