@Test public void process_OldJudgmentNotFound() throws IOException { rJudgment.setJsonContent("12121212esfcsfc"); rJudgment.setJudgmentContentFilename("contentFilename.zip"); when(sourceScJudgmentParser.parseAndValidate(rJudgment.getJsonContent())).thenReturn(sourceScJudgment); scJudgment.getSourceInfo().setSourceJudgmentId("AAAXXX"); scJudgment.getSourceInfo().setSourceCode(SourceCode.SUPREME_COURT); when(sourceScJudgmentConverter.convertJudgment(sourceScJudgment)).thenReturn(jWithCorrectionList); when(judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( Mockito.any(SourceCode.class), Mockito.anyString(), Mockito.any())).thenReturn(null); JudgmentWithCorrectionList<SupremeCourtJudgment> retJWithCorrectionList = scjImportProcessProcessor.process(rJudgment); assertTrue(jWithCorrectionList == retJWithCorrectionList); assertTrue(retJWithCorrectionList.getJudgment() == scJudgment); assertTrue(retJWithCorrectionList.getCorrectionList() == correctionList); assertTrue(rJudgment.isProcessed()); assertNotNull(rJudgment.getProcessingDate()); verify(sourceScJudgmentParser).parseAndValidate(rJudgment.getJsonContent()); verify(sourceScJudgmentConverter).convertJudgment(sourceScJudgment); verify(judgmentRepository).findOneBySourceCodeAndSourceJudgmentId( SourceCode.SUPREME_COURT, scJudgment.getSourceInfo().getSourceJudgmentId(), SupremeCourtJudgment.class); verify(rawSourceJudgmentRepository).save(rJudgment); verify(judgmentContentFileProcessor).processJudgmentContentFile(contentFileTransactionContext, "contentFilename.zip", scJudgment, null); verifyNoMoreInteractions(sourceScJudgmentParser, sourceScJudgmentConverter, judgmentRepository, judgmentContentFileProcessor); verifyZeroInteractions(enrichmentTagRepository); }
@Override public JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment) throws IOException { log.trace("Processing: {} id={}", rJudgment.getClass().getName(), rJudgment.getId()); S sourceJudgment = sourceJudgmentParser.parseAndValidate(rJudgment.getJsonContent()); JudgmentWithCorrectionList<J> judgmentWithCorrectionList = sourceJudgmentConverter.convertJudgment(sourceJudgment); J judgment = judgmentWithCorrectionList.getJudgment(); J oldJudgment = judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( judgment.getSourceInfo().getSourceCode(), judgment.getSourceInfo().getSourceJudgmentId(), judgmentClass); String oldJudgmentContentPath = null; if (oldJudgment != null) { log.trace("same found (rJudgmentId:{}, judgmentId: {}), updating...", rJudgment.getId(), oldJudgment.getId()); oldJudgmentContentPath = oldJudgment.getTextContent().getFilePath(); judgmentOverwriter.overwriteJudgment(oldJudgment, judgment, judgmentWithCorrectionList.getCorrectionList()); enrichmentTagRepository.deleteAllByJudgmentId(oldJudgment.getId()); judgmentWithCorrectionList.setJudgment(oldJudgment); } ContentFileTransactionContext context = (ContentFileTransactionContext) chunkContext.getAttribute("contentFileTransactionContext"); judgmentContentFileProcessor.processJudgmentContentFile(context, rJudgment.getJudgmentContentFilename(), judgmentWithCorrectionList.getJudgment(), oldJudgmentContentPath); markProcessed(rJudgment); return judgmentWithCorrectionList; }
JsonJudgmentImportProcessProcessor implements ItemProcessor<JsonRawSourceJudgment, JudgmentWithCorrectionList<J>> { @Override public JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment) throws IOException { log.trace("Processing: {} id={}", rJudgment.getClass().getName(), rJudgment.getId()); S sourceJudgment = sourceJudgmentParser.parseAndValidate(rJudgment.getJsonContent()); JudgmentWithCorrectionList<J> judgmentWithCorrectionList = sourceJudgmentConverter.convertJudgment(sourceJudgment); J judgment = judgmentWithCorrectionList.getJudgment(); J oldJudgment = judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( judgment.getSourceInfo().getSourceCode(), judgment.getSourceInfo().getSourceJudgmentId(), judgmentClass); String oldJudgmentContentPath = null; if (oldJudgment != null) { log.trace("same found (rJudgmentId:{}, judgmentId: {}), updating...", rJudgment.getId(), oldJudgment.getId()); oldJudgmentContentPath = oldJudgment.getTextContent().getFilePath(); judgmentOverwriter.overwriteJudgment(oldJudgment, judgment, judgmentWithCorrectionList.getCorrectionList()); enrichmentTagRepository.deleteAllByJudgmentId(oldJudgment.getId()); judgmentWithCorrectionList.setJudgment(oldJudgment); } ContentFileTransactionContext context = (ContentFileTransactionContext) chunkContext.getAttribute("contentFileTransactionContext"); judgmentContentFileProcessor.processJudgmentContentFile(context, rJudgment.getJudgmentContentFilename(), judgmentWithCorrectionList.getJudgment(), oldJudgmentContentPath); markProcessed(rJudgment); return judgmentWithCorrectionList; } }
JsonJudgmentImportProcessProcessor implements ItemProcessor<JsonRawSourceJudgment, JudgmentWithCorrectionList<J>> { @Override public JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment) throws IOException { log.trace("Processing: {} id={}", rJudgment.getClass().getName(), rJudgment.getId()); S sourceJudgment = sourceJudgmentParser.parseAndValidate(rJudgment.getJsonContent()); JudgmentWithCorrectionList<J> judgmentWithCorrectionList = sourceJudgmentConverter.convertJudgment(sourceJudgment); J judgment = judgmentWithCorrectionList.getJudgment(); J oldJudgment = judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( judgment.getSourceInfo().getSourceCode(), judgment.getSourceInfo().getSourceJudgmentId(), judgmentClass); String oldJudgmentContentPath = null; if (oldJudgment != null) { log.trace("same found (rJudgmentId:{}, judgmentId: {}), updating...", rJudgment.getId(), oldJudgment.getId()); oldJudgmentContentPath = oldJudgment.getTextContent().getFilePath(); judgmentOverwriter.overwriteJudgment(oldJudgment, judgment, judgmentWithCorrectionList.getCorrectionList()); enrichmentTagRepository.deleteAllByJudgmentId(oldJudgment.getId()); judgmentWithCorrectionList.setJudgment(oldJudgment); } ContentFileTransactionContext context = (ContentFileTransactionContext) chunkContext.getAttribute("contentFileTransactionContext"); judgmentContentFileProcessor.processJudgmentContentFile(context, rJudgment.getJudgmentContentFilename(), judgmentWithCorrectionList.getJudgment(), oldJudgmentContentPath); markProcessed(rJudgment); return judgmentWithCorrectionList; } JsonJudgmentImportProcessProcessor(Class<J> judgmentClass); }
JsonJudgmentImportProcessProcessor implements ItemProcessor<JsonRawSourceJudgment, JudgmentWithCorrectionList<J>> { @Override public JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment) throws IOException { log.trace("Processing: {} id={}", rJudgment.getClass().getName(), rJudgment.getId()); S sourceJudgment = sourceJudgmentParser.parseAndValidate(rJudgment.getJsonContent()); JudgmentWithCorrectionList<J> judgmentWithCorrectionList = sourceJudgmentConverter.convertJudgment(sourceJudgment); J judgment = judgmentWithCorrectionList.getJudgment(); J oldJudgment = judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( judgment.getSourceInfo().getSourceCode(), judgment.getSourceInfo().getSourceJudgmentId(), judgmentClass); String oldJudgmentContentPath = null; if (oldJudgment != null) { log.trace("same found (rJudgmentId:{}, judgmentId: {}), updating...", rJudgment.getId(), oldJudgment.getId()); oldJudgmentContentPath = oldJudgment.getTextContent().getFilePath(); judgmentOverwriter.overwriteJudgment(oldJudgment, judgment, judgmentWithCorrectionList.getCorrectionList()); enrichmentTagRepository.deleteAllByJudgmentId(oldJudgment.getId()); judgmentWithCorrectionList.setJudgment(oldJudgment); } ContentFileTransactionContext context = (ContentFileTransactionContext) chunkContext.getAttribute("contentFileTransactionContext"); judgmentContentFileProcessor.processJudgmentContentFile(context, rJudgment.getJudgmentContentFilename(), judgmentWithCorrectionList.getJudgment(), oldJudgmentContentPath); markProcessed(rJudgment); return judgmentWithCorrectionList; } JsonJudgmentImportProcessProcessor(Class<J> judgmentClass); @BeforeChunk void beforeChunk(ChunkContext context); @Override JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment); void setSourceJudgmentParser(JsonStringParser<S> sourceJudgmentParser); void setSourceJudgmentConverter(JudgmentConverter<J, S> sourceJudgmentConverter); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); void setJudgmentOverwriter(JudgmentOverwriter<J> judgmentOverwriter); @Autowired void setRawSourceJudgmentRepository(RawSourceJudgmentRepository rawSourceJudgmentRepository); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); void setJudgmentContentFileProcessor(JudgmentContentFileProcessor judgmentContentFileHandler); }
JsonJudgmentImportProcessProcessor implements ItemProcessor<JsonRawSourceJudgment, JudgmentWithCorrectionList<J>> { @Override public JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment) throws IOException { log.trace("Processing: {} id={}", rJudgment.getClass().getName(), rJudgment.getId()); S sourceJudgment = sourceJudgmentParser.parseAndValidate(rJudgment.getJsonContent()); JudgmentWithCorrectionList<J> judgmentWithCorrectionList = sourceJudgmentConverter.convertJudgment(sourceJudgment); J judgment = judgmentWithCorrectionList.getJudgment(); J oldJudgment = judgmentRepository.findOneBySourceCodeAndSourceJudgmentId( judgment.getSourceInfo().getSourceCode(), judgment.getSourceInfo().getSourceJudgmentId(), judgmentClass); String oldJudgmentContentPath = null; if (oldJudgment != null) { log.trace("same found (rJudgmentId:{}, judgmentId: {}), updating...", rJudgment.getId(), oldJudgment.getId()); oldJudgmentContentPath = oldJudgment.getTextContent().getFilePath(); judgmentOverwriter.overwriteJudgment(oldJudgment, judgment, judgmentWithCorrectionList.getCorrectionList()); enrichmentTagRepository.deleteAllByJudgmentId(oldJudgment.getId()); judgmentWithCorrectionList.setJudgment(oldJudgment); } ContentFileTransactionContext context = (ContentFileTransactionContext) chunkContext.getAttribute("contentFileTransactionContext"); judgmentContentFileProcessor.processJudgmentContentFile(context, rJudgment.getJudgmentContentFilename(), judgmentWithCorrectionList.getJudgment(), oldJudgmentContentPath); markProcessed(rJudgment); return judgmentWithCorrectionList; } JsonJudgmentImportProcessProcessor(Class<J> judgmentClass); @BeforeChunk void beforeChunk(ChunkContext context); @Override JudgmentWithCorrectionList<J> process(JsonRawSourceJudgment rJudgment); void setSourceJudgmentParser(JsonStringParser<S> sourceJudgmentParser); void setSourceJudgmentConverter(JudgmentConverter<J, S> sourceJudgmentConverter); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); void setJudgmentOverwriter(JudgmentOverwriter<J> judgmentOverwriter); @Autowired void setRawSourceJudgmentRepository(RawSourceJudgmentRepository rawSourceJudgmentRepository); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); void setJudgmentContentFileProcessor(JudgmentContentFileProcessor judgmentContentFileHandler);  }