Extract helper method to ImapResponseHelper
This commit is contained in:
parent
bbf6a07e94
commit
7f3fc84c11
3 changed files with 20 additions and 20 deletions
|
@ -1,16 +1,15 @@
|
||||||
package com.fsck.k9.mail.store.imap;
|
package com.fsck.k9.mail.store.imap;
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fsck.k9.mail.filter.PeekableInputStream;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.mockito.internal.util.collections.Sets;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
@ -116,14 +115,6 @@ public class CapabilityResponseTest {
|
||||||
assertEquals(Sets.newSet("IMAP4REV1", "IDLE"), result.getCapabilities());
|
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 {
|
private CapabilityResponse parse(String responseText) throws IOException {
|
||||||
ImapResponse response = createImapResponse(responseText);
|
ImapResponse response = createImapResponse(responseText);
|
||||||
List<ImapResponse> responses = Collections.singletonList(response);
|
List<ImapResponse> responses = Collections.singletonList(response);
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,14 +1,13 @@
|
||||||
package com.fsck.k9.mail.store.imap;
|
package com.fsck.k9.mail.store.imap;
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import com.fsck.k9.mail.filter.PeekableInputStream;
|
|
||||||
import org.junit.Test;
|
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.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
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 {
|
private NamespaceResponse parse(String response) throws IOException {
|
||||||
ImapResponse imapResponse = createImapResponse(response);
|
ImapResponse imapResponse = createImapResponse(response);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue