@Test(expected=IllegalStateException.class) public void read_FileReaderNull_JsonParserNotNull() throws Exception { JsonParser jsonParser = Mockito.mock(JsonParser.class); when(jsonParser.isClosed()).thenReturn(false); resetDownloadReaderState(Mockito.mock(File.class), null, jsonParser); jsonImportDownloadReader.read(); }
@Override public JsonJudgmentItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (currentFile == null) { return null; } if (fileReader == null) { Preconditions.checkState(jsonParser == null || jsonParser.isClosed()); fileReader = importFileUtils.getReader(currentFile); } if (jsonParser == null || jsonParser.isClosed()) { jsonParser = jsonFactory.createParser(fileReader); } JsonToken jsonToken = jsonParser.nextToken(); if (jsonToken != null && JsonToken.START_ARRAY.equals(jsonToken)) { jsonToken = jsonParser.nextToken(); } if (jsonToken != null) { String judgment = jsonFormatter.formatCurrentTokenTree(jsonParser); if (judgment != null) { return new JsonJudgmentItem(StringUtils.trim(judgment), currentFile); } } closeJsonParser(); closeFileReader(); currentFile = importFiles.poll(); return read(); }
JsonImportDownloadReader implements ItemStreamReader<JsonJudgmentItem> { @Override public JsonJudgmentItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (currentFile == null) { return null; } if (fileReader == null) { Preconditions.checkState(jsonParser == null || jsonParser.isClosed()); fileReader = importFileUtils.getReader(currentFile); } if (jsonParser == null || jsonParser.isClosed()) { jsonParser = jsonFactory.createParser(fileReader); } JsonToken jsonToken = jsonParser.nextToken(); if (jsonToken != null && JsonToken.START_ARRAY.equals(jsonToken)) { jsonToken = jsonParser.nextToken(); } if (jsonToken != null) { String judgment = jsonFormatter.formatCurrentTokenTree(jsonParser); if (judgment != null) { return new JsonJudgmentItem(StringUtils.trim(judgment), currentFile); } } closeJsonParser(); closeFileReader(); currentFile = importFiles.poll(); return read(); } }
JsonImportDownloadReader implements ItemStreamReader<JsonJudgmentItem> { @Override public JsonJudgmentItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (currentFile == null) { return null; } if (fileReader == null) { Preconditions.checkState(jsonParser == null || jsonParser.isClosed()); fileReader = importFileUtils.getReader(currentFile); } if (jsonParser == null || jsonParser.isClosed()) { jsonParser = jsonFactory.createParser(fileReader); } JsonToken jsonToken = jsonParser.nextToken(); if (jsonToken != null && JsonToken.START_ARRAY.equals(jsonToken)) { jsonToken = jsonParser.nextToken(); } if (jsonToken != null) { String judgment = jsonFormatter.formatCurrentTokenTree(jsonParser); if (judgment != null) { return new JsonJudgmentItem(StringUtils.trim(judgment), currentFile); } } closeJsonParser(); closeFileReader(); currentFile = importFiles.poll(); return read(); }  }
JsonImportDownloadReader implements ItemStreamReader<JsonJudgmentItem> { @Override public JsonJudgmentItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (currentFile == null) { return null; } if (fileReader == null) { Preconditions.checkState(jsonParser == null || jsonParser.isClosed()); fileReader = importFileUtils.getReader(currentFile); } if (jsonParser == null || jsonParser.isClosed()) { jsonParser = jsonFactory.createParser(fileReader); } JsonToken jsonToken = jsonParser.nextToken(); if (jsonToken != null && JsonToken.START_ARRAY.equals(jsonToken)) { jsonToken = jsonParser.nextToken(); } if (jsonToken != null) { String judgment = jsonFormatter.formatCurrentTokenTree(jsonParser); if (judgment != null) { return new JsonJudgmentItem(StringUtils.trim(judgment), currentFile); } } closeJsonParser(); closeFileReader(); currentFile = importFiles.poll(); return read(); }  @Override JsonJudgmentItem read(); @Override void open(ExecutionContext executionContext); @Override void update(ExecutionContext executionContext); @Override void close(); void setImportDir(String importDir); @Autowired void setImportFileUtils(ImportFileUtils importFileUtils); @Autowired void setJsonFormatter(JsonFormatter jsonFormatter); @Autowired void setJsonFactory(JsonFactory jsonFactory); }
JsonImportDownloadReader implements ItemStreamReader<JsonJudgmentItem> { @Override public JsonJudgmentItem read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if (currentFile == null) { return null; } if (fileReader == null) { Preconditions.checkState(jsonParser == null || jsonParser.isClosed()); fileReader = importFileUtils.getReader(currentFile); } if (jsonParser == null || jsonParser.isClosed()) { jsonParser = jsonFactory.createParser(fileReader); } JsonToken jsonToken = jsonParser.nextToken(); if (jsonToken != null && JsonToken.START_ARRAY.equals(jsonToken)) { jsonToken = jsonParser.nextToken(); } if (jsonToken != null) { String judgment = jsonFormatter.formatCurrentTokenTree(jsonParser); if (judgment != null) { return new JsonJudgmentItem(StringUtils.trim(judgment), currentFile); } } closeJsonParser(); closeFileReader(); currentFile = importFiles.poll(); return read(); }  @Override JsonJudgmentItem read(); @Override void open(ExecutionContext executionContext); @Override void update(ExecutionContext executionContext); @Override void close(); void setImportDir(String importDir); @Autowired void setImportFileUtils(ImportFileUtils importFileUtils); @Autowired void setJsonFormatter(JsonFormatter jsonFormatter); @Autowired void setJsonFactory(JsonFactory jsonFactory);  }