@Test public void testOneSharedNamespaceShouldWriteNilThenPrefixThenDeliminatorThenNil() throws Exception { final String aPrefix = "A Prefix"; final String aDeliminator = "@"; List<NamespaceResponse.Namespace> namespaces = new ArrayList<>(); namespaces.add(new NamespaceResponse.Namespace(aPrefix, aDeliminator .charAt(0))); subject.encode(new NamespaceResponse(null, null, namespaces), mockComposer); InOrder inOrder = Mockito.inOrder(mockComposer); inOrder.verify(mockComposer, times(1)).untagged(); inOrder.verify(mockComposer, times(1)).commandName(ImapConstants.NAMESPACE_COMMAND); inOrder.verify(mockComposer, times(2)).nil(); inOrder.verify(mockComposer, times(2)).openParen(); inOrder.verify(mockComposer, times(1)).quote(aPrefix + aDeliminator); inOrder.verify(mockComposer, times(1)).quote(aDeliminator); inOrder.verify(mockComposer, times(2)).closeParen(); inOrder.verify(mockComposer, times(1)).end(); }
@Override public void encode(NamespaceResponse response, ImapResponseComposer composer) throws IOException { composer.untagged(); composer.commandName(ImapConstants.NAMESPACE_COMMAND); final List<NamespaceResponse.Namespace> personal = response.getPersonal(); encode(personal, composer); final List<NamespaceResponse.Namespace> users = response.getUsers(); encode(users, composer); final List<NamespaceResponse.Namespace> shared = response.getShared(); encode(shared, composer); composer.end(); }
NamespaceResponseEncoder implements ImapResponseEncoder<NamespaceResponse> { @Override public void encode(NamespaceResponse response, ImapResponseComposer composer) throws IOException { composer.untagged(); composer.commandName(ImapConstants.NAMESPACE_COMMAND); final List<NamespaceResponse.Namespace> personal = response.getPersonal(); encode(personal, composer); final List<NamespaceResponse.Namespace> users = response.getUsers(); encode(users, composer); final List<NamespaceResponse.Namespace> shared = response.getShared(); encode(shared, composer); composer.end(); } }
NamespaceResponseEncoder implements ImapResponseEncoder<NamespaceResponse> { @Override public void encode(NamespaceResponse response, ImapResponseComposer composer) throws IOException { composer.untagged(); composer.commandName(ImapConstants.NAMESPACE_COMMAND); final List<NamespaceResponse.Namespace> personal = response.getPersonal(); encode(personal, composer); final List<NamespaceResponse.Namespace> users = response.getUsers(); encode(users, composer); final List<NamespaceResponse.Namespace> shared = response.getShared(); encode(shared, composer); composer.end(); }  }
NamespaceResponseEncoder implements ImapResponseEncoder<NamespaceResponse> { @Override public void encode(NamespaceResponse response, ImapResponseComposer composer) throws IOException { composer.untagged(); composer.commandName(ImapConstants.NAMESPACE_COMMAND); final List<NamespaceResponse.Namespace> personal = response.getPersonal(); encode(personal, composer); final List<NamespaceResponse.Namespace> users = response.getUsers(); encode(users, composer); final List<NamespaceResponse.Namespace> shared = response.getShared(); encode(shared, composer); composer.end(); }  @Override Class<NamespaceResponse> acceptableMessages(); @Override void encode(NamespaceResponse response, ImapResponseComposer composer); }
NamespaceResponseEncoder implements ImapResponseEncoder<NamespaceResponse> { @Override public void encode(NamespaceResponse response, ImapResponseComposer composer) throws IOException { composer.untagged(); composer.commandName(ImapConstants.NAMESPACE_COMMAND); final List<NamespaceResponse.Namespace> personal = response.getPersonal(); encode(personal, composer); final List<NamespaceResponse.Namespace> users = response.getUsers(); encode(users, composer); final List<NamespaceResponse.Namespace> shared = response.getShared(); encode(shared, composer); composer.end(); }  @Override Class<NamespaceResponse> acceptableMessages(); @Override void encode(NamespaceResponse response, ImapResponseComposer composer);  }