Skip to content

Commit

Permalink
SAK-32252 Update to central mockito version. (sakaiproject#3990)
Browse files Browse the repository at this point in the history
* SAK-32252 Update all mockito verions in pom.xml

This defines a standard mockito version in master/pom.xml and has
everything use that. There are a few tools that use powermock which
isn't yet updated to use the newer mockito 2.x versions in an official
release so until a newer version of powermock comes out I've just
dropped those projects back to the older mockito version.

* SAK-32252 Update of test code for newer mockito 2

This remove unused mock calls from the test classes.
Also updates code as null no longer considered to match on things like Mockito.anyString().
  • Loading branch information
buckett authored Mar 2, 2017
1 parent 3304fe7 commit 67f61d1
Show file tree
Hide file tree
Showing 33 changed files with 46 additions and 88 deletions.
11 changes: 5 additions & 6 deletions assignment/assignment-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
Expand Down
1 change: 0 additions & 1 deletion calendar/calendar-util/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.2.16</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
11 changes: 5 additions & 6 deletions dashboard/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,11 @@
<artifactId>commons-dbcp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.2.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
3 changes: 1 addition & 2 deletions entitybroker/core-providers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
3 changes: 1 addition & 2 deletions external-calendaring-service/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

Expand Down
3 changes: 1 addition & 2 deletions gradebookng/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
3 changes: 1 addition & 2 deletions jobscheduler/scheduler-component-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public void testCreateAndDelete() {
public void testCreateAndDeleteBySearch() {
Time time = Mockito.mock(Time.class);
Mockito.when(time.getTime()).thenReturn(0L);
Mockito.when(dao.get(COMPONENT_ID, CONTEXT)).thenReturn("uuid");
String uuid = manager.createDelayedInvocation(time, COMPONENT_ID, CONTEXT);
manager.deleteDelayedInvocation(COMPONENT_ID, CONTEXT);
DelayedInvocation[] empty = manager.findDelayedInvocations(ALL, ALL);
Expand Down
2 changes: 1 addition & 1 deletion kernel/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<properties>
<deploy.target>shared</deploy.target>
<kernel.basedir>${basedir}/..</kernel.basedir>
<powermock.version>1.6.2</powermock.version>
<powermock.version>1.6.6</powermock.version>
</properties>
<dependencies>
<dependency>
Expand Down
3 changes: 1 addition & 2 deletions kernel/kernel-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public class WrappedContentResourceTest {
@Test
public void testWrapping() throws Exception {
// Check the header and footer get correctly appended.
when(resource.getContent()).thenReturn("body".getBytes());
when(resource.streamContent()).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
Expand Down
7 changes: 3 additions & 4 deletions kernel/kernel-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
8 changes: 3 additions & 5 deletions login/login-tool/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<type>jar</type>
<scope>test</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security.extensions</groupId>
Expand Down
1 change: 0 additions & 1 deletion mailarchive/mailarchive-subetha/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public void testRejectedAddress() throws Exception {
@Test()
public void testIgnorePostmaster() throws Exception {
when(aliasService.getTarget("postmaster")).thenThrow(IdUnusedException.class);
when(rb.getString("err_addr_unknown")).thenReturn("err_addr_unknown");
SmartClient client = createClient();
client.from("[email protected]");
client.to("[email protected]");
Expand Down
1 change: 1 addition & 0 deletions mailsender/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@RunWith(MockitoJUnitRunner.class)
public class ComposeLogicImplTest {
static final String REALM_ID = "composeLogicTest";
static final String SITE_ID = "testSiteId";

@Mock SiteService siteService;
@Mock Site site;
Expand Down Expand Up @@ -70,6 +71,7 @@ public void setUp() throws Exception {
when(toolManager.getCurrentPlacement().getPlacementConfig()).thenReturn(props);

// setup site service
when(externalLogic.getSiteID()).thenReturn(SITE_ID);
when(siteService.getSite(anyString())).thenReturn(site);

// setup site
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ public void sendMailRequiredArgs() throws Exception {

@Test
public void emailArchiveIsNotAddedToSite() throws Exception {
when(site.getTools("sakai.mailbox")).thenReturn(Collections.EMPTY_SET);

MailArchiveChannel channel = mock(MailArchiveChannel.class);
MailArchiveMessageEdit msg = mock(MailArchiveMessageEdit.class);
MailArchiveMessageHeaderEdit header = mock(MailArchiveMessageHeaderEdit.class);
Expand Down Expand Up @@ -356,7 +354,7 @@ public void sendEmailToArchiveWithAttachments() throws Exception {

when(contentHostingService.newResourceProperties()).thenReturn(attachmentProperties);
when(contentHostingService.addAttachmentResource(
anyString(), anyString(), anyString(), anyString(), any(InputStream.class), any(ResourceProperties.class)
anyString(), anyString(), eq(null), anyString(), any(InputStream.class), any(ResourceProperties.class)
)).thenReturn(resource);
when(resource.getReference()).thenReturn("attachmentReference");

Expand Down
7 changes: 0 additions & 7 deletions mailsender/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@
<artifactId>mailsender-impl</artifactId>
<version>${project.version}</version>
</dependency>
<!-- TESTING -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
13 changes: 13 additions & 0 deletions master/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
<sakai.log4j.version>1.2.17</sakai.log4j.version>
<sakai.slf4j.version>1.7.21</sakai.slf4j.version>
<sakai.poi.version>3.14</sakai.poi.version>
<sakai.mockito.version>2.2.16</sakai.mockito.version>
<sakai.okiosid.version>2.0</sakai.okiosid.version>
<joda.time.version>2.9.7</joda.time.version>
<sakai.genericdao.version>0.11.0</sakai.genericdao.version>
Expand Down Expand Up @@ -1693,6 +1694,18 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${sakai.mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${sakai.mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
1 change: 0 additions & 1 deletion polls/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 0 additions & 6 deletions portal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@
<artifactId>velocity</artifactId>
<version>${sakai.velocity.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
11 changes: 6 additions & 5 deletions portal/portal-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@
<artifactId>xom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
Expand Down
1 change: 0 additions & 1 deletion providers/cm-authz-provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;


import org.mockito.runners.MockitoJUnitRunner;
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.api.ServerConfigurationService;
Expand All @@ -17,7 +15,6 @@
import org.sakaiproject.search.api.InvalidSearchQueryException;
import org.sakaiproject.search.api.SearchList;
import org.sakaiproject.search.api.SearchResult;
import org.sakaiproject.search.elasticsearch.filter.SearchItemFilter;
import org.sakaiproject.search.elasticsearch.filter.impl.SearchSecurityFilter;
import org.sakaiproject.search.model.SearchBuilderItem;
import org.sakaiproject.site.api.Site;
Expand All @@ -28,7 +25,6 @@
import java.util.*;

import static org.junit.Assert.*;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;

/**
Expand Down Expand Up @@ -134,8 +130,6 @@ public void createTestResources() {
resources.put(name, resource1);
events.add(newEvent);
when(newEvent.getResource()).thenReturn(resource1.getName());
when(newEvent.getContext()).thenReturn(siteId);
when(entityContentProducer.matches(name)).thenReturn(true);
when(entityContentProducer.matches(newEvent)).thenReturn(true);
when(entityContentProducer.getSiteId(name)).thenReturn(resource1.getSiteId());
when(entityContentProducer.getAction(newEvent)).thenReturn(SearchBuilderItem.ACTION_ADD);
Expand Down Expand Up @@ -167,8 +161,6 @@ public void setUp() throws Exception {
when(serverConfigurationService.getConfigData().getItems()).thenReturn(new ArrayList());
when(serverConfigurationService.getServerId()).thenReturn("server1");
when(serverConfigurationService.getServerName()).thenReturn("clusterName");
when(serverConfigurationService.getString("elasticsearch.index.number_of_shards")).thenReturn("1");
when(serverConfigurationService.getString("elasticsearch.index.number_of_replicas")).thenReturn("0");

when(serverConfigurationService.getSakaiHomePath()).thenReturn(System.getProperty("java.io.tmpdir") + "/" + new Date().getTime());
when(notificationService.addTransientNotification()).thenReturn(notificationEdit);
Expand Down Expand Up @@ -303,10 +295,8 @@ public void testAddingResourceWithNoContent(){
Resource resource = new Resource(null, "xyz", "resource_with_no_content");

when(event.getResource()).thenReturn(resource.getName());
when(entityContentProducer.matches("resource_with_no_content")).thenReturn(false);
List resourceList = new ArrayList();
resourceList.add(resource);
when(entityContentProducer.getSiteContentIterator("xyz")).thenReturn(resourceList.iterator());

elasticSearchIndexBuilder.addResource(notification, event);

Expand Down Expand Up @@ -480,7 +470,6 @@ public void testRebuild(){
when(newEvent.getResource()).thenReturn(resource.getName());
events.add(newEvent);
when(entityContentProducer.matches(newEvent)).thenReturn(true);
when(entityContentProducer.matches(resourceName)).thenReturn(true);

when(entityContentProducer.getSiteId(resourceName)).thenReturn(siteId);
when(entityContentProducer.getAction(newEvent)).thenReturn(SearchBuilderItem.ACTION_ADD);
Expand Down
6 changes: 0 additions & 6 deletions search/elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@
<artifactId>guava</artifactId>
<version>11.0.2</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
1 change: 0 additions & 1 deletion signup/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.4</version>
<scope>test</scope>
</dependency>

Expand Down
1 change: 0 additions & 1 deletion signup/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.4</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion site-manage/site-manage-tool/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
<scope>test</scope>
</dependency>

Expand Down
Loading

0 comments on commit 67f61d1

Please sign in to comment.