@Test @SuppressWarnings("unchecked") public void deserializeResponse_OneClass_ShouldDeserializeAsSingleInstance() { final Class<Object> clazz = Object.class; final String mediaType = "don't/matter"; final Payload payload = new Payload("any serialized payload"); SerializedResponse response = mock(SerializedResponse.class); when(response.getContentType()).thenReturn(mediaType); when(response.getPayload()).thenReturn(payload); when(response.getHeaders()).thenReturn(mock(Headers.class)); Request request = mock(Request.class); Deserializer deserializer = mock(Deserializer.class); when(serdesManager.getDeserializer(clazz, mediaType)).thenReturn(deserializer); engine.deserializeResponse(request, response, clazz); verify(serdesManager).getDeserializer(clazz, mediaType); verify(deserializer, never()).deserialize(any(Class.class), anyString(), any(DeserializationContext.class)); verify(deserializer).deserialize(eq(payload.isString()), any(DeserializationContext.class)); }
public <T, C extends Collection<T>> Response<C> deserializeResponse(Request request, SerializedResponse response, Class<T> type, Class<C> containerType) { final String mediaType = getResponseMediaType(request, response); final Deserializer<T> deserializer = serdesManager.getDeserializer(type, mediaType); checkDeserializerNotNull(response, type, deserializer); final DeserializationContext context = new HttpDeserializationContext(request, response, type, providerManager); C result = deserializer.deserialize(containerType, response.getPayload().isString(), context); return getDeserializedResponse(response, result); }
SerializationEngine { public <T, C extends Collection<T>> Response<C> deserializeResponse(Request request, SerializedResponse response, Class<T> type, Class<C> containerType) { final String mediaType = getResponseMediaType(request, response); final Deserializer<T> deserializer = serdesManager.getDeserializer(type, mediaType); checkDeserializerNotNull(response, type, deserializer); final DeserializationContext context = new HttpDeserializationContext(request, response, type, providerManager); C result = deserializer.deserialize(containerType, response.getPayload().isString(), context); return getDeserializedResponse(response, result); } }
SerializationEngine { public <T, C extends Collection<T>> Response<C> deserializeResponse(Request request, SerializedResponse response, Class<T> type, Class<C> containerType) { final String mediaType = getResponseMediaType(request, response); final Deserializer<T> deserializer = serdesManager.getDeserializer(type, mediaType); checkDeserializerNotNull(response, type, deserializer); final DeserializationContext context = new HttpDeserializationContext(request, response, type, providerManager); C result = deserializer.deserialize(containerType, response.getPayload().isString(), context); return getDeserializedResponse(response, result); } SerializationEngine(SerdesManagerImpl serdesManager, ProviderManagerImpl providerManager); }
SerializationEngine { public <T, C extends Collection<T>> Response<C> deserializeResponse(Request request, SerializedResponse response, Class<T> type, Class<C> containerType) { final String mediaType = getResponseMediaType(request, response); final Deserializer<T> deserializer = serdesManager.getDeserializer(type, mediaType); checkDeserializerNotNull(response, type, deserializer); final DeserializationContext context = new HttpDeserializationContext(request, response, type, providerManager); C result = deserializer.deserialize(containerType, response.getPayload().isString(), context); return getDeserializedResponse(response, result); } SerializationEngine(SerdesManagerImpl serdesManager, ProviderManagerImpl providerManager); Response<C> deserializeResponse(Request request,
                                                                        SerializedResponse response,
                                                                        Class<T> type,
                                                                        Class<C> containerType); Response<T> deserializeResponse(Request request, SerializedResponse response, Class<T> type); SerializedRequestDelegate serializeRequest(Request request); }
SerializationEngine { public <T, C extends Collection<T>> Response<C> deserializeResponse(Request request, SerializedResponse response, Class<T> type, Class<C> containerType) { final String mediaType = getResponseMediaType(request, response); final Deserializer<T> deserializer = serdesManager.getDeserializer(type, mediaType); checkDeserializerNotNull(response, type, deserializer); final DeserializationContext context = new HttpDeserializationContext(request, response, type, providerManager); C result = deserializer.deserialize(containerType, response.getPayload().isString(), context); return getDeserializedResponse(response, result); } SerializationEngine(SerdesManagerImpl serdesManager, ProviderManagerImpl providerManager); Response<C> deserializeResponse(Request request,
                                                                        SerializedResponse response,
                                                                        Class<T> type,
                                                                        Class<C> containerType); Response<T> deserializeResponse(Request request, SerializedResponse response, Class<T> type); SerializedRequestDelegate serializeRequest(Request request);  }