### Question:
DelegatingConverter implements Converter { @Override public Object fromBody(TypedInput body, Type type) throws ConversionException { if (type == Token.class) { return mTokenConverter.fromBody(body, type); } else if (type == MarkAllRead.class) { return mMarkAsReadConverter.fromBody(body, type); } else if (type == SubscriptionResponse.class) { return mSubscriptionConverter.fromBody(body, type); } else if (isListOfDesiredType(type, Post.class)) { return mPostConverter.fromBody(body, type); } else if (isListOfDesiredType(type, Comment.class)) { return mCommentsConverter.fromBody(body, type); } return mOriginalConverter.fromBody(body, type); } DelegatingConverter(Converter originalConverter, TokenConverter tokenConverter,
                               PostConverter postConverter, MarkAsReadConverter markAsReadConverter,
                               SubscriptionConverter subscriptionConverter,
                               CommentsConverter commentsConverter); @Override Object fromBody(TypedInput body, Type type); @Override TypedOutput toBody(Object object);  }### Answer:
@Test public void usesPostConverter_whenParsingPosts() throws Exception { final Type listOfPostsType = getListOfType(Post.class); convertResponse("post-default.json", listOfPostsType); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mTokenConverter); verifyZeroInteractions(mConverter); verify(mPostConverter).fromBody(mTypedInput, listOfPostsType); }
@Test public void usesCommentsConverter_whenParsingComments() throws Exception { final Type listOfPostsType = getListOfType(Comment.class); convertResponse("comments-default.json", listOfPostsType); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mTokenConverter); verifyZeroInteractions(mPostConverter); verifyZeroInteractions(mConverter); verify(mCommentsConverter).fromBody(mTypedInput, listOfPostsType); }
@Test public void usesPostConverter_whenParsingDirectMessages() throws Exception { final Type listOfPostsType = getListOfType(Post.class); convertResponse("post-direct-message.json", listOfPostsType); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mTokenConverter); verifyZeroInteractions(mConverter); verify(mPostConverter).fromBody(mTypedInput, listOfPostsType); }
@Test public void usesPostConverter_whenParsingMarkAsRead() throws Exception { final Type type = MarkAllRead.class; convertResponse("markasread", type); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mTokenConverter); verifyZeroInteractions(mPostConverter); verifyZeroInteractions(mConverter); verify(mMarkAsReadConverter).fromBody(mTypedInput, type); }
@Test public void usesPostConverter_whenParsingTokenRetrieve() throws Exception { final Type type = Token.class; convertResponse("token-retrieve.json", type); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mPostConverter); verifyZeroInteractions(mConverter); verify(mTokenConverter).fromBody(mTypedInput, type); }
@Test public void usesPostConverter_whenParsingTokenRefresh() throws Exception { final Type type = Token.class; convertResponse("token-refresh.json", type); verifyZeroInteractions(mSubscriptionConverter); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mPostConverter); verifyZeroInteractions(mConverter); verify(mTokenConverter).fromBody(mTypedInput, type); }
@Test public void usesPostConverter_whenParsingSubscriptionSync() throws Exception { final Type type = SubscriptionResponse.class; convertResponse("subscriptions-sync.json", type); verifyZeroInteractions(mMarkAsReadConverter); verifyZeroInteractions(mCommentsConverter); verifyZeroInteractions(mTokenConverter); verifyZeroInteractions(mPostConverter); verifyZeroInteractions(mConverter); verify(mSubscriptionConverter).fromBody(mTypedInput, type); }