@Test public void process() throws Exception { String content = "ddsdsdsdskjdjskdjs"; SourceScJudgment sourceScJudgment = new SourceScJudgment(); Source source = new Source(); source.setSourceJudgmentId("1112223334444"); sourceScJudgment.setSource(source); File importFile = new File("judgment.json"); File contentFile = new File("judgment.zip"); Mockito.when(sourceScJudgmentParser.parseAndValidate(Mockito.eq(content))).thenReturn(sourceScJudgment); Mockito.when(contentSourceFileFinder.findContentFile(new File(downloadedContentDir), importFile)).thenReturn(contentFile); RawSourceScJudgment retRJudgment = scjImportProcessor.process(new JsonJudgmentItem(content, new File("judgment.json"))); assertEquals(content, retRJudgment.getJsonContent()); assertEquals(source.getSourceJudgmentId(), retRJudgment.getSourceId()); assertEquals(contentFile.getName(), retRJudgment.getJudgmentContentFilename()); assertNull(retRJudgment.getProcessingDate()); assertFalse(retRJudgment.isProcessed()); }
@Override public T process(JsonJudgmentItem item) throws JsonParseException, InstantiationException, IllegalAccessException { String jsonJudgment = item.getJson(); SourceJudgment sourceJudgment = sourceJudgmentParser.parseAndValidate(jsonJudgment); T rawJudgment = rawSourceJugmentClass.newInstance(); rawJudgment.setJsonContent(jsonJudgment); rawJudgment.setSourceId(sourceJudgment.getSource().getSourceJudgmentId()); File downloadedContentFile = contentSourceFileFinder.findContentFile(new File(downloadedContentDir), item.getSourceMetadataFile()); rawJudgment.setJudgmentContentFilename(downloadedContentFile.getName()); return rawJudgment; }
JsonImportDownloadProcessor implements ItemProcessor<JsonJudgmentItem, T> { @Override public T process(JsonJudgmentItem item) throws JsonParseException, InstantiationException, IllegalAccessException { String jsonJudgment = item.getJson(); SourceJudgment sourceJudgment = sourceJudgmentParser.parseAndValidate(jsonJudgment); T rawJudgment = rawSourceJugmentClass.newInstance(); rawJudgment.setJsonContent(jsonJudgment); rawJudgment.setSourceId(sourceJudgment.getSource().getSourceJudgmentId()); File downloadedContentFile = contentSourceFileFinder.findContentFile(new File(downloadedContentDir), item.getSourceMetadataFile()); rawJudgment.setJudgmentContentFilename(downloadedContentFile.getName()); return rawJudgment; } }
JsonImportDownloadProcessor implements ItemProcessor<JsonJudgmentItem, T> { @Override public T process(JsonJudgmentItem item) throws JsonParseException, InstantiationException, IllegalAccessException { String jsonJudgment = item.getJson(); SourceJudgment sourceJudgment = sourceJudgmentParser.parseAndValidate(jsonJudgment); T rawJudgment = rawSourceJugmentClass.newInstance(); rawJudgment.setJsonContent(jsonJudgment); rawJudgment.setSourceId(sourceJudgment.getSource().getSourceJudgmentId()); File downloadedContentFile = contentSourceFileFinder.findContentFile(new File(downloadedContentDir), item.getSourceMetadataFile()); rawJudgment.setJudgmentContentFilename(downloadedContentFile.getName()); return rawJudgment; } JsonImportDownloadProcessor(Class<T> rawSourceJugmentClass); }
JsonImportDownloadProcessor implements ItemProcessor<JsonJudgmentItem, T> { @Override public T process(JsonJudgmentItem item) throws JsonParseException, InstantiationException, IllegalAccessException { String jsonJudgment = item.getJson(); SourceJudgment sourceJudgment = sourceJudgmentParser.parseAndValidate(jsonJudgment); T rawJudgment = rawSourceJugmentClass.newInstance(); rawJudgment.setJsonContent(jsonJudgment); rawJudgment.setSourceId(sourceJudgment.getSource().getSourceJudgmentId()); File downloadedContentFile = contentSourceFileFinder.findContentFile(new File(downloadedContentDir), item.getSourceMetadataFile()); rawJudgment.setJudgmentContentFilename(downloadedContentFile.getName()); return rawJudgment; } JsonImportDownloadProcessor(Class<T> rawSourceJugmentClass); @Override T process(JsonJudgmentItem item); void setSourceJudgmentParser(JsonStringParser<? extends SourceJudgment> sourceJudgmentParser); @Autowired void setContentSourceFileFinder(ContentSourceFileFinder contentSourceFileFinder); void setDownloadedContentDir(String downloadedContentDir); }
JsonImportDownloadProcessor implements ItemProcessor<JsonJudgmentItem, T> { @Override public T process(JsonJudgmentItem item) throws JsonParseException, InstantiationException, IllegalAccessException { String jsonJudgment = item.getJson(); SourceJudgment sourceJudgment = sourceJudgmentParser.parseAndValidate(jsonJudgment); T rawJudgment = rawSourceJugmentClass.newInstance(); rawJudgment.setJsonContent(jsonJudgment); rawJudgment.setSourceId(sourceJudgment.getSource().getSourceJudgmentId()); File downloadedContentFile = contentSourceFileFinder.findContentFile(new File(downloadedContentDir), item.getSourceMetadataFile()); rawJudgment.setJudgmentContentFilename(downloadedContentFile.getName()); return rawJudgment; } JsonImportDownloadProcessor(Class<T> rawSourceJugmentClass); @Override T process(JsonJudgmentItem item); void setSourceJudgmentParser(JsonStringParser<? extends SourceJudgment> sourceJudgmentParser); @Autowired void setContentSourceFileFinder(ContentSourceFileFinder contentSourceFileFinder); void setDownloadedContentDir(String downloadedContentDir);  }