JsonUtils { public static UpdateInventoryRequest readUpdateInventoryRequest(InputStream in) throws IOException { try (InputStreamReader inputStreamReader = new InputStreamReader(in, UTF_8); BufferedReader br = new BufferedReader(inputStreamReader); JsonReader reader = new JsonReader(br)) { Gson gson = new Gson(); UpdateInventoryRequest message = gson.fromJson(reader, UpdateInventoryRequest.class); return message; } }  static List<DependencyInfo> readDependencies(InputStream in); static List<AgentProjectInfo> readProjects(InputStream in); static UpdateInventoryRequest readUpdateInventoryRequest(InputStream in); static void writeUpdateInventoryRequest(OutputStream out, UpdateInventoryRequest message); static void writeProjects(OutputStream out, List<AgentProjectInfo> projects); static String save(T object, boolean pretty); static T load(final InputStream inputStream, final Class<T> clazz); static List<AgentProjectInfo> readProjectsChunks(InputStream in); static final String UTF_8; }
@Ignore @Test public void shouldDeserialize (){ String currentDir = System.getProperty("user.dir").toString(); File input = Paths.get(currentDir, "\\src\\test\\resources\\plain_request.txt").toFile(); try { try (FileInputStream fileInputStream = new FileInputStream(input)) { UpdateInventoryRequest updateRequest = JsonUtils.readUpdateInventoryRequest(fileInputStream); Assert.assertNotNull(updateRequest); } } catch (IOException e) { Assert.assertNull(e); } }