@Test public void shouldDeserializeProductFromServerResponse() throws Exception { String json = JsonFileReader.readJson(getClass(), "ProductResponse.json"); ProductAdapter productAdapter = new ProductAdapter(); Product deserializedProduct = productAdapter.deserialize(new JsonParser().parse(json), null, null); assertEquals(true, deserializedProduct.isActive()); assertEquals("Comprimidos", deserializedProduct.getType()); assertEquals("Digoxina 0,25mg Comp", deserializedProduct.getPrimaryName()); assertEquals("0,25mg", deserializedProduct.getStrength()); }
@Override public Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Gson().fromJson(json, ProductResponse.class).toProduct(); }
ProductAdapter implements JsonDeserializer<Product> { @Override public Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Gson().fromJson(json, ProductResponse.class).toProduct(); } }
ProductAdapter implements JsonDeserializer<Product> { @Override public Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Gson().fromJson(json, ProductResponse.class).toProduct(); }  }
ProductAdapter implements JsonDeserializer<Product> { @Override public Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Gson().fromJson(json, ProductResponse.class).toProduct(); }  @Override Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context); }
ProductAdapter implements JsonDeserializer<Product> { @Override public Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new Gson().fromJson(json, ProductResponse.class).toProduct(); }  @Override Product deserialize(JsonElement json, java.lang.reflect.Type typeOfT, JsonDeserializationContext context);  }