Upgrade to Mockito 2
This commit is contained in:
parent
0c6209447c
commit
53961b0f73
15 changed files with 185 additions and 142 deletions
|
@ -7,7 +7,7 @@ koinVersion=0.9.1
|
||||||
|
|
||||||
robolectricVersion=3.7.1
|
robolectricVersion=3.7.1
|
||||||
junitVersion=4.12
|
junitVersion=4.12
|
||||||
mockitoVersion=1.10.19
|
mockitoVersion=2.18.0
|
||||||
okioVersion=1.11.0
|
okioVersion=1.11.0
|
||||||
truthVersion=0.35
|
truthVersion=0.35
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anySetOf;
|
import static org.mockito.Matchers.anySetOf;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
|
@ -798,7 +799,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.FLAGS);
|
FetchProfile fetchProfile = createFetchProfile(Item.FLAGS);
|
||||||
|
|
||||||
|
@ -812,7 +813,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.ENVELOPE);
|
FetchProfile fetchProfile = createFetchProfile(Item.ENVELOPE);
|
||||||
|
|
||||||
|
@ -828,7 +829,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.STRUCTURE);
|
FetchProfile fetchProfile = createFetchProfile(Item.STRUCTURE);
|
||||||
|
|
||||||
|
@ -843,7 +844,7 @@ public class ImapFolderTest {
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
String bodyStructure = "(\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 2279 48)";
|
String bodyStructure = "(\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 2279 48)";
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class)))
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class)))
|
||||||
.thenReturn(createImapResponse("* 1 FETCH (BODYSTRUCTURE "+bodyStructure+" UID 1)"))
|
.thenReturn(createImapResponse("* 1 FETCH (BODYSTRUCTURE "+bodyStructure+" UID 1)"))
|
||||||
.thenReturn(createImapResponse("x OK"));
|
.thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
|
@ -859,7 +860,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.BODY_SANE);
|
FetchProfile fetchProfile = createFetchProfile(Item.BODY_SANE);
|
||||||
when(storeConfig.getMaximumAutoDownloadMessageSize()).thenReturn(4096);
|
when(storeConfig.getMaximumAutoDownloadMessageSize()).thenReturn(4096);
|
||||||
|
@ -874,7 +875,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.BODY_SANE);
|
FetchProfile fetchProfile = createFetchProfile(Item.BODY_SANE);
|
||||||
when(storeConfig.getMaximumAutoDownloadMessageSize()).thenReturn(0);
|
when(storeConfig.getMaximumAutoDownloadMessageSize()).thenReturn(0);
|
||||||
|
@ -889,7 +890,7 @@ public class ImapFolderTest {
|
||||||
ImapFolder folder = createFolder("Folder");
|
ImapFolder folder = createFolder("Folder");
|
||||||
prepareImapFolderForOpen(OPEN_MODE_RO);
|
prepareImapFolderForOpen(OPEN_MODE_RO);
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.BODY);
|
FetchProfile fetchProfile = createFetchProfile(Item.BODY);
|
||||||
|
|
||||||
|
@ -905,7 +906,7 @@ public class ImapFolderTest {
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
List<ImapMessage> messages = createImapMessages("1");
|
List<ImapMessage> messages = createImapMessages("1");
|
||||||
FetchProfile fetchProfile = createFetchProfile(Item.FLAGS);
|
FetchProfile fetchProfile = createFetchProfile(Item.FLAGS);
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class)))
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class)))
|
||||||
.thenReturn(createImapResponse("* 1 FETCH (FLAGS (\\Seen) UID 1)"))
|
.thenReturn(createImapResponse("* 1 FETCH (FLAGS (\\Seen) UID 1)"))
|
||||||
.thenReturn(createImapResponse("x OK"));
|
.thenReturn(createImapResponse("x OK"));
|
||||||
|
|
||||||
|
@ -923,7 +924,7 @@ public class ImapFolderTest {
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
ImapMessage message = createImapMessage("1");
|
ImapMessage message = createImapMessage("1");
|
||||||
Part part = createPart("TEXT");
|
Part part = createPart("TEXT");
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
|
|
||||||
folder.fetchPart(message, part, null, null);
|
folder.fetchPart(message, part, null, null);
|
||||||
|
|
||||||
|
@ -937,7 +938,7 @@ public class ImapFolderTest {
|
||||||
folder.open(OPEN_MODE_RO);
|
folder.open(OPEN_MODE_RO);
|
||||||
ImapMessage message = createImapMessage("1");
|
ImapMessage message = createImapMessage("1");
|
||||||
Part part = createPart("1.1");
|
Part part = createPart("1.1");
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class))).thenReturn(createImapResponse("x OK"));
|
||||||
|
|
||||||
folder.fetchPart(message, part, null, null);
|
folder.fetchPart(message, part, null, null);
|
||||||
|
|
||||||
|
@ -1147,7 +1148,7 @@ public class ImapFolderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupSingleFetchResponseToCallback() throws IOException {
|
private void setupSingleFetchResponseToCallback() throws IOException {
|
||||||
when(imapConnection.readResponse(any(ImapResponseCallback.class)))
|
when(imapConnection.readResponse(nullable(ImapResponseCallback.class)))
|
||||||
.thenAnswer(new Answer<ImapResponse>() {
|
.thenAnswer(new Answer<ImapResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public ImapResponse answer(InvocationOnMock invocation) throws Throwable {
|
public ImapResponse answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
|
|
@ -40,6 +40,7 @@ import static java.util.Collections.singletonList;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyBoolean;
|
import static org.mockito.Matchers.anyBoolean;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
|
@ -90,6 +91,8 @@ public class WebDavFolderTest {
|
||||||
when(mockStore.getUrl()).thenReturn(storeUrl);
|
when(mockStore.getUrl()).thenReturn(storeUrl);
|
||||||
when(mockStore.getHttpClient()).thenReturn(mockHttpClient);
|
when(mockStore.getHttpClient()).thenReturn(mockHttpClient);
|
||||||
when(mockStore.getStoreConfig()).thenReturn(mockStoreConfig);
|
when(mockStore.getStoreConfig()).thenReturn(mockStoreConfig);
|
||||||
|
when(mockStore.getMessageEnvelopeXml(any(String[].class))).thenReturn("mockEnvelopeXml");
|
||||||
|
when(mockStore.getMessageFlagsXml(any(String[].class))).thenReturn("mockFlagsXml");
|
||||||
folder = new WebDavFolder(mockStore, folderName);
|
folder = new WebDavFolder(mockStore, folderName);
|
||||||
|
|
||||||
setupTempDirectory();
|
setupTempDirectory();
|
||||||
|
@ -127,6 +130,10 @@ public class WebDavFolderTest {
|
||||||
return webDavMessage;
|
return webDavMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WebDavMessage createWebDavMessage(int uid) {
|
||||||
|
return createWebDavMessage(String.valueOf(uid));
|
||||||
|
}
|
||||||
|
|
||||||
private void setupGetUrlsRequestResponse(String uid, String url) throws MessagingException {
|
private void setupGetUrlsRequestResponse(String uid, String url) throws MessagingException {
|
||||||
String getUrlsXml = "<xml>GetUrls</xml>";
|
String getUrlsXml = "<xml>GetUrls</xml>";
|
||||||
when(mockStore.getMessageUrlsXml(new String[]{uid})).thenReturn(getUrlsXml);
|
when(mockStore.getMessageUrlsXml(new String[]{uid})).thenReturn(getUrlsXml);
|
||||||
|
@ -146,7 +153,7 @@ public class WebDavFolderTest {
|
||||||
|
|
||||||
List<WebDavMessage> messages = new ArrayList<>();
|
List<WebDavMessage> messages = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
WebDavMessage mockMessage = mock(WebDavMessage.class);
|
WebDavMessage mockMessage = createWebDavMessage(i);
|
||||||
messages.add(mockMessage);
|
messages.add(mockMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,7 +170,7 @@ public class WebDavFolderTest {
|
||||||
|
|
||||||
List<WebDavMessage> messages = new ArrayList<>();
|
List<WebDavMessage> messages = new ArrayList<>();
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
WebDavMessage mockMessage = mock(WebDavMessage.class);
|
WebDavMessage mockMessage = createWebDavMessage(i);
|
||||||
messages.add(mockMessage);
|
messages.add(mockMessage);
|
||||||
}
|
}
|
||||||
FetchProfile profile = new FetchProfile();
|
FetchProfile profile = new FetchProfile();
|
||||||
|
@ -179,7 +186,7 @@ public class WebDavFolderTest {
|
||||||
|
|
||||||
List<WebDavMessage> messages = new ArrayList<>();
|
List<WebDavMessage> messages = new ArrayList<>();
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
WebDavMessage mockMessage = mock(WebDavMessage.class);
|
WebDavMessage mockMessage = createWebDavMessage(i);
|
||||||
messages.add(mockMessage);
|
messages.add(mockMessage);
|
||||||
}
|
}
|
||||||
FetchProfile profile = new FetchProfile();
|
FetchProfile profile = new FetchProfile();
|
||||||
|
@ -195,7 +202,7 @@ public class WebDavFolderTest {
|
||||||
|
|
||||||
List<WebDavMessage> messages = new ArrayList<>();
|
List<WebDavMessage> messages = new ArrayList<>();
|
||||||
for (int i = 0; i < 25; i++) {
|
for (int i = 0; i < 25; i++) {
|
||||||
WebDavMessage mockMessage = mock(WebDavMessage.class);
|
WebDavMessage mockMessage = createWebDavMessage(i);
|
||||||
messages.add(mockMessage);
|
messages.add(mockMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +217,7 @@ public class WebDavFolderTest {
|
||||||
setupStoreForMessageFetching();
|
setupStoreForMessageFetching();
|
||||||
List<WebDavMessage> messages = setup25MessagesToFetch();
|
List<WebDavMessage> messages = setup25MessagesToFetch();
|
||||||
|
|
||||||
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), any(HttpContext.class))).thenAnswer(
|
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), nullable(HttpContext.class))).thenAnswer(
|
||||||
new Answer<HttpResponse>() {
|
new Answer<HttpResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
@ -242,7 +249,7 @@ public class WebDavFolderTest {
|
||||||
anyMapOf(String.class, String.class)))
|
anyMapOf(String.class, String.class)))
|
||||||
.thenReturn(mockDataSet);
|
.thenReturn(mockDataSet);
|
||||||
List<WebDavMessage> messages = setup25MessagesToFetch();
|
List<WebDavMessage> messages = setup25MessagesToFetch();
|
||||||
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), any(HttpContext.class))).thenAnswer(
|
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), nullable(HttpContext.class))).thenAnswer(
|
||||||
new Answer<HttpResponse>() {
|
new Answer<HttpResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
@ -290,7 +297,7 @@ public class WebDavFolderTest {
|
||||||
setupStoreForMessageFetching();
|
setupStoreForMessageFetching();
|
||||||
List<WebDavMessage> messages = setup25MessagesToFetch();
|
List<WebDavMessage> messages = setup25MessagesToFetch();
|
||||||
|
|
||||||
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), any(HttpContext.class))).thenAnswer(
|
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), nullable(HttpContext.class))).thenAnswer(
|
||||||
new Answer<HttpResponse>() {
|
new Answer<HttpResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
@ -314,7 +321,7 @@ public class WebDavFolderTest {
|
||||||
setupStoreForMessageFetching();
|
setupStoreForMessageFetching();
|
||||||
List<WebDavMessage> messages = setup25MessagesToFetch();
|
List<WebDavMessage> messages = setup25MessagesToFetch();
|
||||||
|
|
||||||
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), any(HttpContext.class))).thenAnswer(
|
when(mockHttpClient.executeOverride(any(HttpUriRequest.class), nullable(HttpContext.class))).thenAnswer(
|
||||||
new Answer<HttpResponse>() {
|
new Answer<HttpResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
public HttpResponse answer(InvocationOnMock invocation) throws Throwable {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import org.mockito.InOrder;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
import static junit.framework.Assert.fail;
|
import static junit.framework.Assert.fail;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.Matchers.anyString;
|
import static org.mockito.Matchers.anyString;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Mockito.inOrder;
|
import static org.mockito.Mockito.inOrder;
|
||||||
|
@ -55,7 +55,7 @@ public class SmtpTransportTest {
|
||||||
public void before() throws AuthenticationFailedException {
|
public void before() throws AuthenticationFailedException {
|
||||||
socketFactory = TestTrustedSocketFactory.newInstance();
|
socketFactory = TestTrustedSocketFactory.newInstance();
|
||||||
oAuth2TokenProvider = mock(OAuth2TokenProvider.class);
|
oAuth2TokenProvider = mock(OAuth2TokenProvider.class);
|
||||||
when(oAuth2TokenProvider.getToken(eq(USERNAME), anyInt()))
|
when(oAuth2TokenProvider.getToken(eq(USERNAME), anyLong()))
|
||||||
.thenReturn("oldToken").thenReturn("newToken");
|
.thenReturn("oldToken").thenReturn("newToken");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ public class SmtpTransportTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
||||||
server.verifyConnectionClosed();
|
server.verifyConnectionClosed();
|
||||||
server.verifyInteractionCompleted();
|
server.verifyInteractionCompleted();
|
||||||
|
@ -323,9 +323,9 @@ public class SmtpTransportTest {
|
||||||
transport.open();
|
transport.open();
|
||||||
|
|
||||||
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
server.verifyConnectionStillOpen();
|
server.verifyConnectionStillOpen();
|
||||||
server.verifyInteractionCompleted();
|
server.verifyInteractionCompleted();
|
||||||
}
|
}
|
||||||
|
@ -349,9 +349,9 @@ public class SmtpTransportTest {
|
||||||
transport.open();
|
transport.open();
|
||||||
|
|
||||||
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
server.verifyConnectionStillOpen();
|
server.verifyConnectionStillOpen();
|
||||||
server.verifyInteractionCompleted();
|
server.verifyInteractionCompleted();
|
||||||
}
|
}
|
||||||
|
@ -375,9 +375,9 @@ public class SmtpTransportTest {
|
||||||
transport.open();
|
transport.open();
|
||||||
|
|
||||||
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
server.verifyConnectionStillOpen();
|
server.verifyConnectionStillOpen();
|
||||||
server.verifyInteractionCompleted();
|
server.verifyInteractionCompleted();
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,8 @@ public class SmtpTransportTest {
|
||||||
server.output("250 AUTH XOAUTH2");
|
server.output("250 AUTH XOAUTH2");
|
||||||
server.expect("QUIT");
|
server.expect("QUIT");
|
||||||
server.output("221 BYE");
|
server.output("221 BYE");
|
||||||
when(oAuth2TokenProvider.getToken(anyString(), anyInt())).thenThrow(new AuthenticationFailedException("Failed to fetch token"));
|
when(oAuth2TokenProvider.getToken(anyString(), anyLong()))
|
||||||
|
.thenThrow(new AuthenticationFailedException("Failed to fetch token"));
|
||||||
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
|
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -592,7 +593,7 @@ public class SmtpTransportTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
InOrder inOrder = inOrder(oAuth2TokenProvider);
|
||||||
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
|
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyLong());
|
||||||
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
|
||||||
server.verifyConnectionClosed();
|
server.verifyConnectionClosed();
|
||||||
server.verifyInteractionCompleted();
|
server.verifyInteractionCompleted();
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||||
import static android.provider.ContactsContract.CommonDataKinds.Email.TYPE_HOME;
|
import static android.provider.ContactsContract.CommonDataKinds.Email.TYPE_HOME;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.AdditionalMatchers.aryEq;
|
import static org.mockito.AdditionalMatchers.aryEq;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
import static org.mockito.Matchers.isNull;
|
import static org.mockito.Matchers.isNull;
|
||||||
|
@ -158,9 +159,9 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
|
|
||||||
when(contentResolver
|
when(contentResolver
|
||||||
.query(eq(Uri.parse("content://" + CRYPTO_PROVIDER + ".provider.exported/autocrypt_status")),
|
.query(eq(Uri.parse("content://" + CRYPTO_PROVIDER + ".provider.exported/autocrypt_status")),
|
||||||
aryEq(PROJECTION_CRYPTO_ADDRESSES), any(String.class),
|
aryEq(PROJECTION_CRYPTO_ADDRESSES), nullable(String.class),
|
||||||
aryEq(new String[] { queriedAddress }),
|
aryEq(new String[] { queriedAddress }),
|
||||||
any(String.class))).thenReturn(cursor);
|
nullable(String.class))).thenReturn(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupCryptoProviderStatus(Address address, String uidStatus, String autocryptStatus) {
|
private void setupCryptoProviderStatus(Address address, String uidStatus, String autocryptStatus) {
|
||||||
|
@ -169,9 +170,9 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
|
|
||||||
when(contentResolver
|
when(contentResolver
|
||||||
.query(eq(Uri.parse("content://" + CRYPTO_PROVIDER + ".provider.exported/autocrypt_status")),
|
.query(eq(Uri.parse("content://" + CRYPTO_PROVIDER + ".provider.exported/autocrypt_status")),
|
||||||
aryEq(PROJECTION_CRYPTO_STATUS), any(String.class),
|
aryEq(PROJECTION_CRYPTO_STATUS), nullable(String.class),
|
||||||
aryEq(new String[] { address.getAddress() }),
|
aryEq(new String[] { address.getAddress() }),
|
||||||
any(String.class))).thenReturn(cursorCryptoStatus);
|
nullable(String.class))).thenReturn(cursorCryptoStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupContactProvider(String queriedAddress, String[]... contacts) {
|
private void setupContactProvider(String queriedAddress, String[]... contacts) {
|
||||||
|
@ -182,9 +183,9 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
when(contentResolver
|
when(contentResolver
|
||||||
.query(eq(Email.CONTENT_URI),
|
.query(eq(Email.CONTENT_URI),
|
||||||
aryEq(PROJECTION),
|
aryEq(PROJECTION),
|
||||||
any(String.class),
|
nullable(String.class),
|
||||||
aryEq(new String[] { queriedAddress, queriedAddress }),
|
aryEq(new String[] { queriedAddress, queriedAddress }),
|
||||||
any(String.class))).thenReturn(cursor);
|
nullable(String.class))).thenReturn(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupNicknameContactProvider(String[]... contactsWithNickname) {
|
private void setupNicknameContactProvider(String[]... contactsWithNickname) {
|
||||||
|
@ -195,9 +196,9 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
when(contentResolver
|
when(contentResolver
|
||||||
.query(eq(ContactsContract.Data.CONTENT_URI),
|
.query(eq(ContactsContract.Data.CONTENT_URI),
|
||||||
aryEq(PROJECTION_NICKNAME),
|
aryEq(PROJECTION_NICKNAME),
|
||||||
any(String.class),
|
nullable(String.class),
|
||||||
any(String[].class),
|
nullable(String[].class),
|
||||||
any(String.class))).thenReturn(cursor);
|
nullable(String.class))).thenReturn(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupContactProviderForId(String id, String[]... contacts) {
|
private void setupContactProviderForId(String id, String[]... contacts) {
|
||||||
|
@ -208,9 +209,9 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
when(contentResolver
|
when(contentResolver
|
||||||
.query(eq(Email.CONTENT_URI),
|
.query(eq(Email.CONTENT_URI),
|
||||||
aryEq(PROJECTION),
|
aryEq(PROJECTION),
|
||||||
any(String.class),
|
nullable(String.class),
|
||||||
aryEq(new String[] { id }),
|
aryEq(new String[] { id }),
|
||||||
any(String.class))).thenReturn(cursor);
|
nullable(String.class))).thenReturn(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -300,7 +301,7 @@ public class RecipientLoaderTest extends RobolectricTest {
|
||||||
aryEq(PROJECTION),
|
aryEq(PROJECTION),
|
||||||
isNull(String.class),
|
isNull(String.class),
|
||||||
isNull(String[].class),
|
isNull(String[].class),
|
||||||
any(String.class))).thenReturn(cursor);
|
nullable(String.class))).thenReturn(cursor);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,8 @@ public class RecipientPresenterTest extends K9RobolectricTest {
|
||||||
recipientPresenter.initFromReplyToMessage(message, false);
|
recipientPresenter.initFromReplyToMessage(message, false);
|
||||||
runBackgroundTask();
|
runBackgroundTask();
|
||||||
|
|
||||||
verify(recipientMvpView).addRecipients(eq(RecipientType.TO), any(Recipient[].class));
|
Recipient toRecipient = new Recipient(TO_ADDRESSES.to[0]);
|
||||||
|
verify(recipientMvpView).addRecipients(eq(RecipientType.TO), eq(toRecipient));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Captor;
|
import org.mockito.Captor;
|
||||||
import org.mockito.InOrder;
|
import org.mockito.InOrder;
|
||||||
import org.mockito.Matchers;
|
import org.mockito.Matchers;
|
||||||
|
@ -55,6 +56,9 @@ import org.robolectric.shadows.ShadowLog;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyList;
|
||||||
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.anySet;
|
import static org.mockito.Matchers.anySet;
|
||||||
|
@ -374,7 +378,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
|
|
||||||
controller.searchLocalMessagesSynchronous(search, listener);
|
controller.searchLocalMessagesSynchronous(search, listener);
|
||||||
|
|
||||||
verify(localStore).searchForMessages(any(MessageRetrievalListener.class), eq(search));
|
verify(localStore).searchForMessages(nullable(MessageRetrievalListener.class), eq(search));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -384,7 +388,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
LocalMessage localMessage = mock(LocalMessage.class);
|
LocalMessage localMessage = mock(LocalMessage.class);
|
||||||
when(localMessage.getFolder()).thenReturn(localFolder);
|
when(localMessage.getFolder()).thenReturn(localFolder);
|
||||||
when(search.getAccountUuids()).thenReturn(new String[]{"allAccounts"});
|
when(search.getAccountUuids()).thenReturn(new String[]{"allAccounts"});
|
||||||
when(localStore.searchForMessages(any(MessageRetrievalListener.class), eq(search)))
|
when(localStore.searchForMessages(nullable(MessageRetrievalListener.class), eq(search)))
|
||||||
.thenThrow(new MessagingException("Test"));
|
.thenThrow(new MessagingException("Test"));
|
||||||
|
|
||||||
controller.searchLocalMessagesSynchronous(search, listener);
|
controller.searchLocalMessagesSynchronous(search, listener);
|
||||||
|
@ -410,7 +414,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
when(remoteNewMessage2.getUid()).thenReturn("newMessageUid2");
|
when(remoteNewMessage2.getUid()).thenReturn("newMessageUid2");
|
||||||
when(localNewMessage2.getUid()).thenReturn("newMessageUid2");
|
when(localNewMessage2.getUid()).thenReturn("newMessageUid2");
|
||||||
when(remoteFolder.search(anyString(), anySet(), anySet())).thenReturn(remoteMessages);
|
when(remoteFolder.search(anyString(), anySet(), anySet())).thenReturn(remoteMessages);
|
||||||
when(localFolder.extractNewMessages(Matchers.<List<Message>>any())).thenReturn(newRemoteMessages);
|
when(localFolder.extractNewMessages(ArgumentMatchers.<Message>anyList())).thenReturn(newRemoteMessages);
|
||||||
when(localFolder.getMessage("newMessageUid1")).thenReturn(localNewMessage1);
|
when(localFolder.getMessage("newMessageUid1")).thenReturn(localNewMessage1);
|
||||||
when(localFolder.getMessage("newMessageUid2")).thenAnswer(
|
when(localFolder.getMessage("newMessageUid2")).thenAnswer(
|
||||||
new Answer<LocalMessage>() {
|
new Answer<LocalMessage>() {
|
||||||
|
@ -431,9 +435,9 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).when(remoteFolder).fetch(
|
}).when(remoteFolder).fetch(
|
||||||
Matchers.<List<Message>>eq(Collections.singletonList(remoteNewMessage2)),
|
eq(Collections.singletonList(remoteNewMessage2)),
|
||||||
any(FetchProfile.class),
|
any(FetchProfile.class),
|
||||||
Matchers.<MessageRetrievalListener>eq(null));
|
isNull(MessageRetrievalListener.class));
|
||||||
reqFlags = Collections.singleton(Flag.ANSWERED);
|
reqFlags = Collections.singleton(Flag.ANSWERED);
|
||||||
forbiddenFlags = Collections.singleton(Flag.DELETED);
|
forbiddenFlags = Collections.singleton(Flag.DELETED);
|
||||||
|
|
||||||
|
@ -715,7 +719,7 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
LocalMessage localCopyOfRemoteDeletedMessage = mock(LocalMessage.class);
|
LocalMessage localCopyOfRemoteDeletedMessage = mock(LocalMessage.class);
|
||||||
when(account.syncRemoteDeletions()).thenReturn(true);
|
when(account.syncRemoteDeletions()).thenReturn(true);
|
||||||
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
|
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
|
||||||
when(localFolder.getMessagesByUids(any(List.class)))
|
when(localFolder.getMessagesByUids(ArgumentMatchers.<String>anyList()))
|
||||||
.thenReturn(Collections.singletonList(localCopyOfRemoteDeletedMessage));
|
.thenReturn(Collections.singletonList(localCopyOfRemoteDeletedMessage));
|
||||||
|
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
@ -751,7 +755,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
when(account.getEarliestPollDate()).thenReturn(dateOfEarliestPoll);
|
when(account.getEarliestPollDate()).thenReturn(dateOfEarliestPoll);
|
||||||
when(localMessage.olderThan(dateOfEarliestPoll)).thenReturn(true);
|
when(localMessage.olderThan(dateOfEarliestPoll)).thenReturn(true);
|
||||||
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
|
when(localFolder.getAllMessagesAndEffectiveDates()).thenReturn(Collections.singletonMap(MESSAGE_UID1, 0L));
|
||||||
when(localFolder.getMessagesByUids(any(List.class))).thenReturn(Collections.singletonList(localMessage));
|
when(localFolder.getMessagesByUids(ArgumentMatchers.<String>anyList()))
|
||||||
|
.thenReturn(Collections.singletonList(localMessage));
|
||||||
|
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
|
||||||
|
@ -782,8 +787,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
|
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
|
||||||
verify(remoteFolder, atLeastOnce()).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeastOnce()).fetch(anyList(), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.FLAGS));
|
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.FLAGS));
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
||||||
assertEquals(2, fetchProfileCaptor.getAllValues().get(0).size());
|
assertEquals(2, fetchProfileCaptor.getAllValues().get(0).size());
|
||||||
|
@ -799,8 +804,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
|
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
|
||||||
verify(remoteFolder, atLeastOnce()).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeastOnce()).fetch(anyList(), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(0).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(0).size());
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
||||||
}
|
}
|
||||||
|
@ -817,8 +822,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
|
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
|
||||||
verify(remoteFolder, atLeast(2)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeast(2)).fetch(anyList(), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(1).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(1).size());
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(1).contains(FetchProfile.Item.BODY));
|
assertTrue(fetchProfileCaptor.getAllValues().get(1).contains(FetchProfile.Item.BODY));
|
||||||
}
|
}
|
||||||
|
@ -836,8 +841,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
controller.synchronizeMailboxSynchronousLegacy(account, FOLDER_NAME, listener);
|
||||||
|
|
||||||
//TODO: Don't bother fetching messages of a size we don't have
|
//TODO: Don't bother fetching messages of a size we don't have
|
||||||
verify(remoteFolder, atLeast(4)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeast(4)).fetch(anyList(), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(2).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(2).size());
|
||||||
assertEquals(FetchProfile.Item.STRUCTURE, fetchProfileCaptor.getAllValues().get(2).get(0));
|
assertEquals(FetchProfile.Item.STRUCTURE, fetchProfileCaptor.getAllValues().get(2).get(0));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(3).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(3).size());
|
||||||
|
@ -887,19 +892,19 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).when(remoteFolder).fetch(any(List.class), any(FetchProfile.class), any(MessageRetrievalListener.class));
|
}).when(remoteFolder).fetch(anyList(), any(FetchProfile.class), nullable(MessageRetrievalListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message buildSmallNewMessage() {
|
private Message buildSmallNewMessage() {
|
||||||
Message message = mock(Message.class);
|
Message message = mock(Message.class);
|
||||||
when(message.olderThan(any(Date.class))).thenReturn(false);
|
when(message.olderThan(nullable(Date.class))).thenReturn(false);
|
||||||
when(message.getSize()).thenReturn((long) MAXIMUM_SMALL_MESSAGE_SIZE);
|
when(message.getSize()).thenReturn((long) MAXIMUM_SMALL_MESSAGE_SIZE);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message buildLargeNewMessage() {
|
private Message buildLargeNewMessage() {
|
||||||
Message message = mock(Message.class);
|
Message message = mock(Message.class);
|
||||||
when(message.olderThan(any(Date.class))).thenReturn(false);
|
when(message.olderThan(nullable(Date.class))).thenReturn(false);
|
||||||
when(message.getSize()).thenReturn((long) (MAXIMUM_SMALL_MESSAGE_SIZE + 1));
|
when(message.getSize()).thenReturn((long) (MAXIMUM_SMALL_MESSAGE_SIZE + 1));
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -915,8 +920,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
|
|
||||||
when(remoteMessage.getUid()).thenReturn(messageUid);
|
when(remoteMessage.getUid()).thenReturn(messageUid);
|
||||||
when(localMessage.getUid()).thenReturn(messageUid);
|
when(localMessage.getUid()).thenReturn(messageUid);
|
||||||
when(remoteFolder.getMessages(anyInt(), anyInt(), any(Date.class), any(MessageRetrievalListener.class)))
|
when(remoteFolder.getMessages(anyInt(), anyInt(), nullable(Date.class),
|
||||||
.thenReturn(Collections.singletonList(remoteMessage));
|
nullable(MessageRetrievalListener.class))).thenReturn(Collections.singletonList(remoteMessage));
|
||||||
return localMessage;
|
return localMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,8 +929,8 @@ public class MessagingControllerTest extends K9RobolectricTest {
|
||||||
String messageUid = "UID";
|
String messageUid = "UID";
|
||||||
Message remoteMessage = mock(Message.class);
|
Message remoteMessage = mock(Message.class);
|
||||||
when(remoteMessage.getUid()).thenReturn(messageUid);
|
when(remoteMessage.getUid()).thenReturn(messageUid);
|
||||||
when(remoteFolder.getMessages(anyInt(), anyInt(), any(Date.class), any(MessageRetrievalListener.class)))
|
when(remoteFolder.getMessages(anyInt(), anyInt(), nullable(Date.class),
|
||||||
.thenReturn(Collections.singletonList(remoteMessage));
|
nullable(MessageRetrievalListener.class))).thenReturn(Collections.singletonList(remoteMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureAccount() throws MessagingException {
|
private void configureAccount() throws MessagingException {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.robolectric.shadows.ShadowLog;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Mockito.atLeast;
|
import static org.mockito.Mockito.atLeast;
|
||||||
|
@ -253,7 +254,7 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
imapSync.sync(account, FOLDER_NAME, listener, remoteFolder);
|
imapSync.sync(account, FOLDER_NAME, listener, remoteFolder);
|
||||||
|
|
||||||
verify(remoteFolder, atLeastOnce()).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeastOnce()).fetch(any(List.class), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.FLAGS));
|
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.FLAGS));
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
assertTrue(fetchProfileCaptor.getAllValues().get(0).contains(FetchProfile.Item.ENVELOPE));
|
||||||
assertEquals(2, fetchProfileCaptor.getAllValues().get(0).size());
|
assertEquals(2, fetchProfileCaptor.getAllValues().get(0).size());
|
||||||
|
@ -270,7 +271,7 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
imapSync.sync(account, FOLDER_NAME, listener, remoteFolder);
|
imapSync.sync(account, FOLDER_NAME, listener, remoteFolder);
|
||||||
|
|
||||||
verify(remoteFolder, atLeast(2)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeast(2)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(1).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(1).size());
|
||||||
assertTrue(fetchProfileCaptor.getAllValues().get(1).contains(FetchProfile.Item.BODY));
|
assertTrue(fetchProfileCaptor.getAllValues().get(1).contains(FetchProfile.Item.BODY));
|
||||||
}
|
}
|
||||||
|
@ -287,7 +288,7 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
|
|
||||||
//TODO: Don't bother fetching messages of a size we don't have
|
//TODO: Don't bother fetching messages of a size we don't have
|
||||||
verify(remoteFolder, atLeast(4)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
verify(remoteFolder, atLeast(4)).fetch(any(List.class), fetchProfileCaptor.capture(),
|
||||||
any(MessageRetrievalListener.class));
|
nullable(MessageRetrievalListener.class));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(2).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(2).size());
|
||||||
assertEquals(FetchProfile.Item.STRUCTURE, fetchProfileCaptor.getAllValues().get(2).get(0));
|
assertEquals(FetchProfile.Item.STRUCTURE, fetchProfileCaptor.getAllValues().get(2).get(0));
|
||||||
assertEquals(1, fetchProfileCaptor.getAllValues().get(3).size());
|
assertEquals(1, fetchProfileCaptor.getAllValues().get(3).size());
|
||||||
|
@ -309,19 +310,19 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}).when(remoteFolder).fetch(any(List.class), any(FetchProfile.class), any(MessageRetrievalListener.class));
|
}).when(remoteFolder).fetch(any(List.class), any(FetchProfile.class), nullable(MessageRetrievalListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message buildSmallNewMessage() {
|
private Message buildSmallNewMessage() {
|
||||||
Message message = mock(Message.class);
|
Message message = mock(Message.class);
|
||||||
when(message.olderThan(any(Date.class))).thenReturn(false);
|
when(message.olderThan(nullable(Date.class))).thenReturn(false);
|
||||||
when(message.getSize()).thenReturn((long) MAXIMUM_SMALL_MESSAGE_SIZE);
|
when(message.getSize()).thenReturn((long) MAXIMUM_SMALL_MESSAGE_SIZE);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message buildLargeNewMessage() {
|
private Message buildLargeNewMessage() {
|
||||||
Message message = mock(Message.class);
|
Message message = mock(Message.class);
|
||||||
when(message.olderThan(any(Date.class))).thenReturn(false);
|
when(message.olderThan(nullable(Date.class))).thenReturn(false);
|
||||||
when(message.getSize()).thenReturn((long) (MAXIMUM_SMALL_MESSAGE_SIZE + 1));
|
when(message.getSize()).thenReturn((long) (MAXIMUM_SMALL_MESSAGE_SIZE + 1));
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -337,8 +338,8 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
|
|
||||||
when(remoteMessage.getUid()).thenReturn(messageUid);
|
when(remoteMessage.getUid()).thenReturn(messageUid);
|
||||||
when(localMessage.getUid()).thenReturn(messageUid);
|
when(localMessage.getUid()).thenReturn(messageUid);
|
||||||
when(remoteFolder.getMessages(anyInt(), anyInt(), any(Date.class), any(MessageRetrievalListener.class)))
|
when(remoteFolder.getMessages(anyInt(), anyInt(), nullable(Date.class),
|
||||||
.thenReturn(Collections.singletonList(remoteMessage));
|
nullable(MessageRetrievalListener.class))).thenReturn(Collections.singletonList(remoteMessage));
|
||||||
return localMessage;
|
return localMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,16 +347,16 @@ public class ImapSyncTest extends RobolectricTest {
|
||||||
String messageUid = "UID";
|
String messageUid = "UID";
|
||||||
Message remoteMessage = mock(Message.class);
|
Message remoteMessage = mock(Message.class);
|
||||||
when(remoteMessage.getUid()).thenReturn(messageUid);
|
when(remoteMessage.getUid()).thenReturn(messageUid);
|
||||||
when(remoteFolder.getMessages(anyInt(), anyInt(), any(Date.class), any(MessageRetrievalListener.class)))
|
when(remoteFolder.getMessages(anyInt(), anyInt(), nullable(Date.class),
|
||||||
.thenReturn(Collections.singletonList(remoteMessage));
|
nullable(MessageRetrievalListener.class))).thenReturn(Collections.singletonList(remoteMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpMessagingController() throws MessagingException {
|
private void setUpMessagingController() throws MessagingException {
|
||||||
when(controller.getAccountStats(account)).thenReturn(accountStats);
|
when(controller.getAccountStats(account)).thenReturn(accountStats);
|
||||||
when(controller.getListeners(any(MessagingListener.class))).thenAnswer(new Answer<Set<MessagingListener>>() {
|
when(controller.getListeners(nullable(MessagingListener.class))).thenAnswer(new Answer<Set<MessagingListener>>() {
|
||||||
@Override
|
@Override
|
||||||
public Set<MessagingListener> answer(InvocationOnMock invocation) throws Throwable {
|
public Set<MessagingListener> answer(InvocationOnMock invocation) throws Throwable {
|
||||||
MessagingListener listener = invocation.getArgumentAt(0, MessagingListener.class);
|
MessagingListener listener = invocation.getArgument(0);
|
||||||
Set<MessagingListener> set = new HashSet<>(1);
|
Set<MessagingListener> set = new HashSet<>(1);
|
||||||
set.add(listener);
|
set.add(listener);
|
||||||
return set;
|
return set;
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.robolectric.RuntimeEnvironment;
|
||||||
import static com.fsck.k9.autocrypt.AutocryptOperationsHelper.assertMessageHasAutocryptHeader;
|
import static com.fsck.k9.autocrypt.AutocryptOperationsHelper.assertMessageHasAutocryptHeader;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
|
@ -164,7 +165,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntent);
|
.thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
|
@ -184,8 +185,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_DETACHED_SIGNATURE, new byte[] { 1, 2, 3 });
|
returnIntent.putExtra(OpenPgpApi.RESULT_DETACHED_SIGNATURE, new byte[] { 1, 2, 3 });
|
||||||
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class),
|
||||||
.thenReturn(returnIntent);
|
nullable(OutputStream.class))).thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.buildAsync(mockCallback);
|
pgpMessageBuilder.buildAsync(mockCallback);
|
||||||
|
@ -236,7 +237,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
when(returnIntent.getParcelableExtra(eq(OpenPgpApi.RESULT_INTENT)))
|
when(returnIntent.getParcelableExtra(eq(OpenPgpApi.RESULT_INTENT)))
|
||||||
.thenReturn(mockPendingIntent);
|
.thenReturn(mockPendingIntent);
|
||||||
|
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntent);
|
.thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
|
@ -264,7 +265,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
when(returnIntent.getParcelableExtra(eq(OpenPgpApi.RESULT_INTENT)))
|
when(returnIntent.getParcelableExtra(eq(OpenPgpApi.RESULT_INTENT)))
|
||||||
.thenReturn(mockPendingIntent);
|
.thenReturn(mockPendingIntent);
|
||||||
|
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntent);
|
.thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
|
@ -285,12 +286,13 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
|
||||||
Intent mockReturnIntent = mock(Intent.class);
|
Intent mockReturnIntent = mock(Intent.class);
|
||||||
when(openPgpApi.executeApi(same(mockReturnIntent), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(same(mockReturnIntent), any(OpenPgpDataSource.class),
|
||||||
.thenReturn(returnIntent);
|
nullable(OutputStream.class))).thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.onActivityResult(returnedRequestCode, Activity.RESULT_OK, mockReturnIntent, mockCallback);
|
pgpMessageBuilder.onActivityResult(returnedRequestCode, Activity.RESULT_OK, mockReturnIntent, mockCallback);
|
||||||
verify(openPgpApi).executeApi(same(mockReturnIntent), any(OpenPgpDataSource.class), any(OutputStream.class));
|
verify(openPgpApi).executeApi(same(mockReturnIntent), any(OpenPgpDataSource.class),
|
||||||
|
nullable(OutputStream.class));
|
||||||
verify(returnIntent).getIntExtra(eq(OpenPgpApi.RESULT_CODE), anyInt());
|
verify(returnIntent).getIntExtra(eq(OpenPgpApi.RESULT_CODE), anyInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -304,7 +306,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
|
|
||||||
Intent returnIntent = spy(new Intent());
|
Intent returnIntent = spy(new Intent());
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntent);
|
.thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
|
@ -326,7 +328,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class))).thenReturn(returnIntent);
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
|
.thenReturn(returnIntent);
|
||||||
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
||||||
|
|
||||||
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("alice@example.org"));
|
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("alice@example.org"));
|
||||||
|
@ -347,7 +350,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class))).thenReturn(returnIntent);
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
|
.thenReturn(returnIntent);
|
||||||
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
||||||
|
|
||||||
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("alice@example.org"));
|
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForUserId(same(openPgpApi), eq("alice@example.org"));
|
||||||
|
@ -367,7 +371,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class))).thenReturn(returnIntent);
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
|
.thenReturn(returnIntent);
|
||||||
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
pgpMessageBuilder.buildAsync(mock(Callback.class));
|
||||||
|
|
||||||
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(any(OpenPgpApi.class), any(Long.class), any(String.class));
|
verify(autocryptOpenPgpApiInteractor).getKeyMaterialForKeyId(any(OpenPgpApi.class), any(Long.class), any(String.class));
|
||||||
|
@ -387,8 +392,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
|
||||||
when(openPgpApi.executeApi(capturedApiIntent.capture(),
|
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class),
|
||||||
any(OpenPgpDataSource.class), any(OutputStream.class))).thenReturn(returnIntent);
|
nullable(OutputStream.class))).thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.buildAsync(mockCallback);
|
pgpMessageBuilder.buildAsync(mockCallback);
|
||||||
|
@ -441,8 +446,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
|
||||||
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class),
|
||||||
.thenReturn(returnIntent);
|
nullable(OutputStream.class))).thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.buildAsync(mockCallback);
|
pgpMessageBuilder.buildAsync(mockCallback);
|
||||||
|
@ -480,8 +485,8 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
returnIntent.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS);
|
||||||
|
|
||||||
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(capturedApiIntent.capture(), any(OpenPgpDataSource.class),
|
||||||
.thenReturn(returnIntent);
|
nullable(OutputStream.class))).thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.buildAsync(mockCallback);
|
pgpMessageBuilder.buildAsync(mockCallback);
|
||||||
|
@ -550,7 +555,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
new OpenPgpError(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, "Missing keys"));
|
new OpenPgpError(OpenPgpError.OPPORTUNISTIC_MISSING_KEYS, "Missing keys"));
|
||||||
|
|
||||||
|
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntent);
|
.thenReturn(returnIntent);
|
||||||
|
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
|
@ -577,7 +582,7 @@ public class PgpMessageBuilderTest extends K9RobolectricTest {
|
||||||
// no OpenPgpApi.EXTRA_DETACHED_SIGNATURE!
|
// no OpenPgpApi.EXTRA_DETACHED_SIGNATURE!
|
||||||
|
|
||||||
|
|
||||||
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), any(OutputStream.class)))
|
when(openPgpApi.executeApi(any(Intent.class), any(OpenPgpDataSource.class), nullable(OutputStream.class)))
|
||||||
.thenReturn(returnIntentSigned);
|
.thenReturn(returnIntentSigned);
|
||||||
Callback mockCallback = mock(Callback.class);
|
Callback mockCallback = mock(Callback.class);
|
||||||
pgpMessageBuilder.buildAsync(mockCallback);
|
pgpMessageBuilder.buildAsync(mockCallback);
|
||||||
|
|
|
@ -16,8 +16,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -30,6 +28,7 @@ public class AuthenticationErrorNotificationsTest extends RobolectricTest {
|
||||||
private static final String ACCOUNT_NAME = "TestAccount";
|
private static final String ACCOUNT_NAME = "TestAccount";
|
||||||
|
|
||||||
|
|
||||||
|
private Notification notification;
|
||||||
private NotificationManagerCompat notificationManager;
|
private NotificationManagerCompat notificationManager;
|
||||||
private NotificationCompat.Builder builder;
|
private NotificationCompat.Builder builder;
|
||||||
private NotificationController controller;
|
private NotificationController controller;
|
||||||
|
@ -40,8 +39,9 @@ public class AuthenticationErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
notification = createFakeNotification();
|
||||||
notificationManager = createFakeNotificationManager();
|
notificationManager = createFakeNotificationManager();
|
||||||
builder = createFakeNotificationBuilder();
|
builder = createFakeNotificationBuilder(notification);
|
||||||
controller = createFakeNotificationController(notificationManager, builder);
|
controller = createFakeNotificationController(notificationManager, builder);
|
||||||
account = createFakeAccount();
|
account = createFakeAccount();
|
||||||
contentIntent = createFakeContentIntent();
|
contentIntent = createFakeContentIntent();
|
||||||
|
@ -55,7 +55,7 @@ public class AuthenticationErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
authenticationErrorNotifications.showAuthenticationErrorNotification(account, INCOMING);
|
authenticationErrorNotifications.showAuthenticationErrorNotification(account, INCOMING);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
assertAuthenticationErrorNotificationContents();
|
assertAuthenticationErrorNotificationContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class AuthenticationErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
authenticationErrorNotifications.showAuthenticationErrorNotification(account, OUTGOING);
|
authenticationErrorNotifications.showAuthenticationErrorNotification(account, OUTGOING);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
assertAuthenticationErrorNotificationContents();
|
assertAuthenticationErrorNotificationContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,12 +96,18 @@ public class AuthenticationErrorNotificationsTest extends RobolectricTest {
|
||||||
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Notification createFakeNotification() {
|
||||||
|
return mock(Notification.class);
|
||||||
|
}
|
||||||
|
|
||||||
private NotificationManagerCompat createFakeNotificationManager() {
|
private NotificationManagerCompat createFakeNotificationManager() {
|
||||||
return mock(NotificationManagerCompat.class);
|
return mock(NotificationManagerCompat.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder createFakeNotificationBuilder() {
|
private Builder createFakeNotificationBuilder(Notification notification) {
|
||||||
return MockHelper.mockBuilder(NotificationCompat.Builder.class);
|
Builder builder = MockHelper.mockBuilder(Builder.class);
|
||||||
|
when(builder.build()).thenReturn(notification);
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
||||||
|
|
|
@ -16,8 +16,6 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -30,6 +28,7 @@ public class CertificateErrorNotificationsTest extends RobolectricTest {
|
||||||
private static final String ACCOUNT_NAME = "TestAccount";
|
private static final String ACCOUNT_NAME = "TestAccount";
|
||||||
|
|
||||||
|
|
||||||
|
private Notification notification;
|
||||||
private NotificationManagerCompat notificationManager;
|
private NotificationManagerCompat notificationManager;
|
||||||
private NotificationCompat.Builder builder;
|
private NotificationCompat.Builder builder;
|
||||||
private NotificationController controller;
|
private NotificationController controller;
|
||||||
|
@ -40,8 +39,9 @@ public class CertificateErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
notification = createFakeNotification();
|
||||||
notificationManager = createFakeNotificationManager();
|
notificationManager = createFakeNotificationManager();
|
||||||
builder = createFakeNotificationBuilder();
|
builder = createFakeNotificationBuilder(notification);
|
||||||
controller = createFakeNotificationController(notificationManager, builder);
|
controller = createFakeNotificationController(notificationManager, builder);
|
||||||
account = createFakeAccount();
|
account = createFakeAccount();
|
||||||
contentIntent = createFakeContentIntent();
|
contentIntent = createFakeContentIntent();
|
||||||
|
@ -55,7 +55,7 @@ public class CertificateErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
certificateErrorNotifications.showCertificateErrorNotification(account, INCOMING);
|
certificateErrorNotifications.showCertificateErrorNotification(account, INCOMING);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
assertCertificateErrorNotificationContents();
|
assertCertificateErrorNotificationContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ public class CertificateErrorNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
certificateErrorNotifications.showCertificateErrorNotification(account, OUTGOING);
|
certificateErrorNotifications.showCertificateErrorNotification(account, OUTGOING);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
assertCertificateErrorNotificationContents();
|
assertCertificateErrorNotificationContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,12 +96,18 @@ public class CertificateErrorNotificationsTest extends RobolectricTest {
|
||||||
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Notification createFakeNotification() {
|
||||||
|
return mock(Notification.class);
|
||||||
|
}
|
||||||
|
|
||||||
private NotificationManagerCompat createFakeNotificationManager() {
|
private NotificationManagerCompat createFakeNotificationManager() {
|
||||||
return mock(NotificationManagerCompat.class);
|
return mock(NotificationManagerCompat.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder createFakeNotificationBuilder() {
|
private Builder createFakeNotificationBuilder(Notification notification) {
|
||||||
return MockHelper.mockBuilder(NotificationCompat.Builder.class);
|
Builder builder = MockHelper.mockBuilder(Builder.class);
|
||||||
|
when(builder.build()).thenReturn(notification);
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -28,6 +27,7 @@ public class SendFailedNotificationsTest extends RobolectricTest {
|
||||||
private static final String ACCOUNT_NAME = "TestAccount";
|
private static final String ACCOUNT_NAME = "TestAccount";
|
||||||
|
|
||||||
|
|
||||||
|
private Notification notification;
|
||||||
private NotificationManagerCompat notificationManager;
|
private NotificationManagerCompat notificationManager;
|
||||||
private Builder builder;
|
private Builder builder;
|
||||||
private Account account;
|
private Account account;
|
||||||
|
@ -38,8 +38,9 @@ public class SendFailedNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
notification = createFakeNotification();
|
||||||
notificationManager = createFakeNotificationManager();
|
notificationManager = createFakeNotificationManager();
|
||||||
builder = createFakeNotificationBuilder();
|
builder = createFakeNotificationBuilder(notification);
|
||||||
NotificationController controller = createFakeNotificationController(notificationManager, builder);
|
NotificationController controller = createFakeNotificationController(notificationManager, builder);
|
||||||
account = createFakeAccount();
|
account = createFakeAccount();
|
||||||
contentIntent = createFakeContentIntent();
|
contentIntent = createFakeContentIntent();
|
||||||
|
@ -55,7 +56,7 @@ public class SendFailedNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
sendFailedNotifications.showSendFailedNotification(account, exception);
|
sendFailedNotifications.showSendFailedNotification(account, exception);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail);
|
verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail);
|
||||||
verify(builder).setTicker("Failed to send some messages");
|
verify(builder).setTicker("Failed to send some messages");
|
||||||
verify(builder).setContentTitle("Failed to send some messages");
|
verify(builder).setContentTitle("Failed to send some messages");
|
||||||
|
@ -71,12 +72,18 @@ public class SendFailedNotificationsTest extends RobolectricTest {
|
||||||
verify(notificationManager).cancel(notificationId);
|
verify(notificationManager).cancel(notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Notification createFakeNotification() {
|
||||||
|
return mock(Notification.class);
|
||||||
|
}
|
||||||
|
|
||||||
private NotificationManagerCompat createFakeNotificationManager() {
|
private NotificationManagerCompat createFakeNotificationManager() {
|
||||||
return mock(NotificationManagerCompat.class);
|
return mock(NotificationManagerCompat.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder createFakeNotificationBuilder() {
|
private Builder createFakeNotificationBuilder(Notification notification) {
|
||||||
return MockHelper.mockBuilder(Builder.class);
|
Builder builder = MockHelper.mockBuilder(Builder.class);
|
||||||
|
when(builder.build()).thenReturn(notification);
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
||||||
|
|
|
@ -16,10 +16,10 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.anyInt;
|
import static org.mockito.Matchers.anyInt;
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -32,6 +32,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
private static final String FOLDER_NAME = "Inbox";
|
private static final String FOLDER_NAME = "Inbox";
|
||||||
|
|
||||||
|
|
||||||
|
private Notification notification;
|
||||||
private NotificationManagerCompat notificationManager;
|
private NotificationManagerCompat notificationManager;
|
||||||
private Builder builder;
|
private Builder builder;
|
||||||
private Account account;
|
private Account account;
|
||||||
|
@ -41,8 +42,9 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
|
notification = createFakeNotification();
|
||||||
notificationManager = createFakeNotificationManager();
|
notificationManager = createFakeNotificationManager();
|
||||||
builder = createFakeNotificationBuilder();
|
builder = createFakeNotificationBuilder(notification);
|
||||||
NotificationController controller = createFakeNotificationController(notificationManager, builder);
|
NotificationController controller = createFakeNotificationController(notificationManager, builder);
|
||||||
account = createFakeAccount();
|
account = createFakeAccount();
|
||||||
contentIntent = createFakeContentIntent();
|
contentIntent = createFakeContentIntent();
|
||||||
|
@ -57,7 +59,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
syncNotifications.showSendingNotification(account);
|
syncNotifications.showSendingNotification(account);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail);
|
verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail);
|
||||||
verify(builder).setTicker("Sending mail: " + ACCOUNT_NAME);
|
verify(builder).setTicker("Sending mail: " + ACCOUNT_NAME);
|
||||||
verify(builder).setContentTitle("Sending mail");
|
verify(builder).setContentTitle("Sending mail");
|
||||||
|
@ -82,7 +84,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
syncNotifications.showFetchingMailNotification(account, folder);
|
syncNotifications.showFetchingMailNotification(account, folder);
|
||||||
|
|
||||||
verify(notificationManager).notify(eq(notificationId), any(Notification.class));
|
verify(notificationManager).notify(notificationId, notification);
|
||||||
verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail);
|
verify(builder).setSmallIcon(R.drawable.ic_notify_check_mail);
|
||||||
verify(builder).setTicker("Checking mail: " + ACCOUNT_NAME + ":" + FOLDER_NAME);
|
verify(builder).setTicker("Checking mail: " + ACCOUNT_NAME + ":" + FOLDER_NAME);
|
||||||
verify(builder).setContentTitle("Checking mail");
|
verify(builder).setContentTitle("Checking mail");
|
||||||
|
@ -100,12 +102,19 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
verify(notificationManager).cancel(notificationId);
|
verify(notificationManager).cancel(notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Notification createFakeNotification() {
|
||||||
|
return mock(Notification.class);
|
||||||
|
}
|
||||||
|
|
||||||
private NotificationManagerCompat createFakeNotificationManager() {
|
private NotificationManagerCompat createFakeNotificationManager() {
|
||||||
return mock(NotificationManagerCompat.class);
|
return mock(NotificationManagerCompat.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Builder createFakeNotificationBuilder() {
|
private Builder createFakeNotificationBuilder(Notification notification) {
|
||||||
return MockHelper.mockBuilder(Builder.class);
|
Builder builder = MockHelper.mockBuilder(Builder.class);
|
||||||
|
when(builder.build()).thenReturn(notification);
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
private NotificationController createFakeNotificationController(NotificationManagerCompat notificationManager,
|
||||||
|
@ -122,6 +131,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
Account account = mock(Account.class);
|
Account account = mock(Account.class);
|
||||||
when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
|
when(account.getAccountNumber()).thenReturn(ACCOUNT_NUMBER);
|
||||||
when(account.getDescription()).thenReturn(ACCOUNT_NAME);
|
when(account.getDescription()).thenReturn(ACCOUNT_NAME);
|
||||||
|
when(account.getOutboxFolder()).thenReturn("OUTBOX");
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +142,7 @@ public class SyncNotificationsTest extends RobolectricTest {
|
||||||
|
|
||||||
private NotificationActionCreator createActionBuilder(PendingIntent contentIntent) {
|
private NotificationActionCreator createActionBuilder(PendingIntent contentIntent) {
|
||||||
NotificationActionCreator actionBuilder = mock(NotificationActionCreator.class);
|
NotificationActionCreator actionBuilder = mock(NotificationActionCreator.class);
|
||||||
when(actionBuilder.createViewFolderPendingIntent(any(Account.class), anyString(), anyInt()))
|
when(actionBuilder.createViewFolderPendingIntent(eq(account), anyString(), anyInt()))
|
||||||
.thenReturn(contentIntent);
|
.thenReturn(contentIntent);
|
||||||
return actionBuilder;
|
return actionBuilder;
|
||||||
}
|
}
|
||||||
|
|
|
@ -306,7 +306,7 @@ public class WearNotificationsTest extends RobolectricTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class ActionMatcher extends ArgumentMatcher<WearableExtender> {
|
static class ActionMatcher implements ArgumentMatcher<WearableExtender> {
|
||||||
private int icon;
|
private int icon;
|
||||||
private String title;
|
private String title;
|
||||||
private PendingIntent pendingIntent;
|
private PendingIntent pendingIntent;
|
||||||
|
@ -318,13 +318,8 @@ public class WearNotificationsTest extends RobolectricTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Object argument) {
|
public boolean matches(WearableExtender argument) {
|
||||||
if (!(argument instanceof WearableExtender)) {
|
for (Action action : argument.getActions()) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WearableExtender wearableExtender = (WearableExtender) argument;
|
|
||||||
for (Action action : wearableExtender.getActions()) {
|
|
||||||
if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
|
if (action.icon == icon && action.title.equals(title) && action.actionIntent == pendingIntent) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +329,7 @@ public class WearNotificationsTest extends RobolectricTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class NumberOfActionsMatcher extends ArgumentMatcher<WearableExtender> {
|
static class NumberOfActionsMatcher implements ArgumentMatcher<WearableExtender> {
|
||||||
private final int expectedNumberOfActions;
|
private final int expectedNumberOfActions;
|
||||||
|
|
||||||
public NumberOfActionsMatcher(int expectedNumberOfActions) {
|
public NumberOfActionsMatcher(int expectedNumberOfActions) {
|
||||||
|
@ -342,13 +337,8 @@ public class WearNotificationsTest extends RobolectricTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(Object argument) {
|
public boolean matches(WearableExtender argument) {
|
||||||
if (!(argument instanceof WearableExtender)) {
|
return argument.getActions().size() == expectedNumberOfActions;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WearableExtender wearableExtender = (WearableExtender) argument;
|
|
||||||
return wearableExtender.getActions().size() == expectedNumberOfActions;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import static com.fsck.k9.message.TestMessageConstructionUtils.multipart;
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static junit.framework.Assert.assertSame;
|
import static junit.framework.Assert.assertSame;
|
||||||
import static junit.framework.Assert.assertTrue;
|
import static junit.framework.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
import static org.mockito.Matchers.same;
|
import static org.mockito.Matchers.same;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
@ -63,7 +64,8 @@ public class MessageCryptoHelperTest extends RobolectricTest {
|
||||||
autocryptOperations = mock(AutocryptOperations.class);
|
autocryptOperations = mock(AutocryptOperations.class);
|
||||||
|
|
||||||
OpenPgpApiFactory openPgpApiFactory = mock(OpenPgpApiFactory.class);
|
OpenPgpApiFactory openPgpApiFactory = mock(OpenPgpApiFactory.class);
|
||||||
when(openPgpApiFactory.createOpenPgpApi(any(Context.class), any(IOpenPgpService2.class))).thenReturn(openPgpApi);
|
when(openPgpApiFactory.createOpenPgpApi(any(Context.class), nullable(IOpenPgpService2.class)))
|
||||||
|
.thenReturn(openPgpApi);
|
||||||
|
|
||||||
messageCryptoHelper = new MessageCryptoHelper(RuntimeEnvironment.application, openPgpApiFactory,
|
messageCryptoHelper = new MessageCryptoHelper(RuntimeEnvironment.application, openPgpApiFactory,
|
||||||
autocryptOperations, "org.example.dummy");
|
autocryptOperations, "org.example.dummy");
|
||||||
|
|
Loading…
Reference in a new issue