From 7f3fc84c112f4403a856b0953650a7b4a52215ac Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 2 Feb 2016 05:00:49 +0100 Subject: [PATCH] Extract helper method to ImapResponseHelper --- .../store/imap/CapabilityResponseTest.java | 11 +---------- .../k9/mail/store/imap/ImapResponseHelper.java | 18 ++++++++++++++++++ .../mail/store/imap/NamespaceResponseTest.java | 11 +---------- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseHelper.java diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/CapabilityResponseTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/CapabilityResponseTest.java index 6e81b63a6..e82670cf6 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/CapabilityResponseTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/CapabilityResponseTest.java @@ -1,16 +1,15 @@ package com.fsck.k9.mail.store.imap; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Arrays; import java.util.Collections; import java.util.List; -import com.fsck.k9.mail.filter.PeekableInputStream; import org.junit.Test; import org.mockito.internal.util.collections.Sets; +import static com.fsck.k9.mail.store.imap.ImapResponseHelper.createImapResponse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -116,14 +115,6 @@ public class CapabilityResponseTest { assertEquals(Sets.newSet("IMAP4REV1", "IDLE"), result.getCapabilities()); } - private ImapResponse createImapResponse(String response) throws IOException { - String input = response + "\r\n"; - PeekableInputStream inputStream = new PeekableInputStream(new ByteArrayInputStream(input.getBytes())); - ImapResponseParser parser = new ImapResponseParser(inputStream); - - return parser.readResponse(); - } - private CapabilityResponse parse(String responseText) throws IOException { ImapResponse response = createImapResponse(responseText); List responses = Collections.singletonList(response); diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseHelper.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseHelper.java new file mode 100644 index 000000000..ff27565b0 --- /dev/null +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapResponseHelper.java @@ -0,0 +1,18 @@ +package com.fsck.k9.mail.store.imap; + + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import com.fsck.k9.mail.filter.PeekableInputStream; + + +public class ImapResponseHelper { + public static ImapResponse createImapResponse(String response) throws IOException { + String input = response + "\r\n"; + PeekableInputStream inputStream = new PeekableInputStream(new ByteArrayInputStream(input.getBytes())); + ImapResponseParser parser = new ImapResponseParser(inputStream); + + return parser.readResponse(); + } +} diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/NamespaceResponseTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/NamespaceResponseTest.java index d31fa563d..2c157ffcd 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/NamespaceResponseTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/NamespaceResponseTest.java @@ -1,14 +1,13 @@ package com.fsck.k9.mail.store.imap; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Arrays; import java.util.Collections; -import com.fsck.k9.mail.filter.PeekableInputStream; import org.junit.Test; +import static com.fsck.k9.mail.store.imap.ImapResponseHelper.createImapResponse; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -96,14 +95,6 @@ public class NamespaceResponseTest { } - private ImapResponse createImapResponse(String response) throws IOException { - String input = response + "\r\n"; - PeekableInputStream inputStream = new PeekableInputStream(new ByteArrayInputStream(input.getBytes())); - ImapResponseParser parser = new ImapResponseParser(inputStream); - - return parser.readResponse(); - } - private NamespaceResponse parse(String response) throws IOException { ImapResponse imapResponse = createImapResponse(response);