@Test public void shouldBeAbleToDeserializeACatWhenMethodHasMoreThanOneArgument() throws Exception { InputStream stream = new ByteArrayInputStream("{\"cat\":{\"name\": \"Zulu\", \"age\": 1}}".getBytes()); when(provider.parameterNamesFor(jump.getMethod())).thenReturn(new String[] {"cat", "times"}); Object[] deserialized = deserializer.deserialize(stream, jump); assertThat(deserialized.length, is(2)); assertThat(deserialized[0], is(instanceOf(Cat.class))); Cat cat = (Cat) deserialized[0]; assertThat(cat.name, is("Zulu")); assertThat(cat.age, is(1)); }
public Object[] deserialize(InputStream inputStream, ResourceMethod method) { Method javaMethod = method.getMethod(); Class<?>[] types = javaMethod.getParameterTypes(); checkArgument(types.length > 0, "Methods that consumes representations must receive just one argument: the root element"); XStream xStream = getConfiguredXStream(javaMethod, types); Object[] params = new Object[types.length]; chooseParam(types, params, xStream.fromXML(inputStream)); return params; }
JsonDeserializer implements Deserializer { public Object[] deserialize(InputStream inputStream, ResourceMethod method) { Method javaMethod = method.getMethod(); Class<?>[] types = javaMethod.getParameterTypes(); checkArgument(types.length > 0, "Methods that consumes representations must receive just one argument: the root element"); XStream xStream = getConfiguredXStream(javaMethod, types); Object[] params = new Object[types.length]; chooseParam(types, params, xStream.fromXML(inputStream)); return params; } }
JsonDeserializer implements Deserializer { public Object[] deserialize(InputStream inputStream, ResourceMethod method) { Method javaMethod = method.getMethod(); Class<?>[] types = javaMethod.getParameterTypes(); checkArgument(types.length > 0, "Methods that consumes representations must receive just one argument: the root element"); XStream xStream = getConfiguredXStream(javaMethod, types); Object[] params = new Object[types.length]; chooseParam(types, params, xStream.fromXML(inputStream)); return params; } JsonDeserializer(ParameterNameProvider provider,TypeNameExtractor extractor, XStreamBuilder builder); }
JsonDeserializer implements Deserializer { public Object[] deserialize(InputStream inputStream, ResourceMethod method) { Method javaMethod = method.getMethod(); Class<?>[] types = javaMethod.getParameterTypes(); checkArgument(types.length > 0, "Methods that consumes representations must receive just one argument: the root element"); XStream xStream = getConfiguredXStream(javaMethod, types); Object[] params = new Object[types.length]; chooseParam(types, params, xStream.fromXML(inputStream)); return params; } JsonDeserializer(ParameterNameProvider provider,TypeNameExtractor extractor, XStreamBuilder builder); Object[] deserialize(InputStream inputStream, ResourceMethod method); XStream getConfiguredXStream(Method javaMethod, Class<?>[] types); }
JsonDeserializer implements Deserializer { public Object[] deserialize(InputStream inputStream, ResourceMethod method) { Method javaMethod = method.getMethod(); Class<?>[] types = javaMethod.getParameterTypes(); checkArgument(types.length > 0, "Methods that consumes representations must receive just one argument: the root element"); XStream xStream = getConfiguredXStream(javaMethod, types); Object[] params = new Object[types.length]; chooseParam(types, params, xStream.fromXML(inputStream)); return params; } JsonDeserializer(ParameterNameProvider provider,TypeNameExtractor extractor, XStreamBuilder builder); Object[] deserialize(InputStream inputStream, ResourceMethod method); XStream getConfiguredXStream(Method javaMethod, Class<?>[] types);  }