Skip to content

Commit

Permalink
Eliminate mocks from ViewTest (jenkinsci#6378)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Mar 16, 2022
1 parent 18144e3 commit 1f9d510
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions test/src/test/java/hudson/model/ViewTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;

import com.cloudbees.hudson.plugins.folder.Folder;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
Expand Down Expand Up @@ -647,9 +645,9 @@ public void testAllViewNotCreatedIfPrimary() {
public void shouldFindNestedViewByName() throws Exception {
//given
String testNestedViewName = "right2ndNestedView";
View right2ndNestedView = mockedViewWithName(testNestedViewName);
View right2ndNestedView = new ListView(testNestedViewName);
//and
View left2ndNestedView = mockedViewWithName("left2ndNestedView");
View left2ndNestedView = new ListView("left2ndNestedView");
DummyCompositeView rightNestedGroupView = new DummyCompositeView("rightNestedGroupView", left2ndNestedView, right2ndNestedView);
//and
listView("leftTopLevelView");
Expand All @@ -660,10 +658,6 @@ public void shouldFindNestedViewByName() throws Exception {
assertEquals(right2ndNestedView, foundNestedView);
}

private View mockedViewWithName(String viewName) {
return given(mock(View.class).getViewName()).willReturn(viewName).getMock();
}

public void prepareSec1923() {
j.jenkins.setSecurityRealm(j.createDummySecurityRealm());
MockAuthorizationStrategy mas = new MockAuthorizationStrategy();
Expand Down

0 comments on commit 1f9d510

Please sign in to comment.