@Test public void convert() { ReferencedRegulationsTagValueItem refRegulationItem1 = new ReferencedRegulationsTagValueItem(); refRegulationItem1.setJournalYear(1964); refRegulationItem1.setJournalNo(0); refRegulationItem1.setJournalEntry(296); refRegulationItem1.setJournalTitle("Ustawa z dnia 17 listopada 1964 r. - Kodeks postępowania cywilnego"); refRegulationItem1.setText("Ustawa z dnia 17 listopada 1964 r. - Kodeks postępowania cywilnego (Dz. U. z 1964 r. Nr 43, poz. 296 - art. 391; art. 98)"); LawJournalEntry dbLawJournalEntry1 = new LawJournalEntry(1964, 43, 296, "Ustawa z dnia 17 listopada 1964 r. - Kodeks postępowania cywilnego"); when(lawJournalEntryRepository.findOneByYearAndEntry(1964, 296)).thenReturn(dbLawJournalEntry1); ReferencedRegulationsTagValueItem refRegulationItem2 = new ReferencedRegulationsTagValueItem(); refRegulationItem2.setJournalYear(1999); refRegulationItem2.setJournalNo(83); refRegulationItem2.setJournalEntry(930); refRegulationItem2.setJournalTitle("Ustawa z dnia 10 września 1999 r. - Kodeks karny skarbowy KKS"); refRegulationItem2.setText("Ustawa z dnia 10 września 1999 r. - Kodeks karny skarbowy (Dz. U. z 1999 r. Nr 83, poz. 930 - art. 107; art. 107 § 1)"); LawJournalEntry dbLawJournalEntry2 = new LawJournalEntry(1999, 83, 930, "Ustawa z dnia 10 września 1999 r. - Kodeks karny skarbowy"); when(lawJournalEntryRepository.findOneByYearAndEntry(1999, 930)).thenReturn(dbLawJournalEntry2); ReferencedRegulationsTagValueItem[] refRegulationsTagValueItems = new ReferencedRegulationsTagValueItem[] { refRegulationItem1, refRegulationItem2 }; List<JudgmentReferencedRegulation> referencedRegulations = referencedRegulationsTagValueConverter.convert(refRegulationsTagValueItems); assertEquals(2, referencedRegulations.size()); JudgmentReferencedRegulation referencedRegulation1 = referencedRegulations.get(0); LawJournalEntry lawJournalEntry1 = referencedRegulation1.getLawJournalEntry(); assertEquals(dbLawJournalEntry1.getYear(), lawJournalEntry1.getYear()); assertEquals(dbLawJournalEntry1.getJournalNo(), lawJournalEntry1.getJournalNo()); assertEquals(dbLawJournalEntry1.getEntry(), lawJournalEntry1.getEntry()); assertEquals(dbLawJournalEntry1.getTitle(), lawJournalEntry1.getTitle()); assertEquals(refRegulationItem1.getText(), referencedRegulation1.getRawText()); assertTrue(referencedRegulation1.isGenerated()); JudgmentReferencedRegulation referencedRegulation2 = referencedRegulations.get(1); LawJournalEntry lawJournalEntry2 = referencedRegulation2.getLawJournalEntry(); assertEquals(dbLawJournalEntry2.getYear(), lawJournalEntry2.getYear()); assertEquals(dbLawJournalEntry2.getJournalNo(), lawJournalEntry2.getJournalNo()); assertEquals(dbLawJournalEntry2.getEntry(), lawJournalEntry2.getEntry()); assertEquals(dbLawJournalEntry2.getTitle(), lawJournalEntry2.getTitle()); assertEquals(refRegulationItem2.getText(), referencedRegulation2.getRawText()); assertTrue(referencedRegulation2.isGenerated()); }
@Override public List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems) { Preconditions.checkNotNull(refrencedRegulationsTagValueItems); List<JudgmentReferencedRegulation> referencedRegulations = Lists.newArrayList(); for (ReferencedRegulationsTagValueItem referencedRegulationsTagValueItem : refrencedRegulationsTagValueItems) { referencedRegulations.add(convert(referencedRegulationsTagValueItem)); } return referencedRegulations; }
ReferencedRegulationsTagValueConverter implements EnrichmentTagValueConverter<ReferencedRegulationsTagValueItem[], List<JudgmentReferencedRegulation>> { @Override public List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems) { Preconditions.checkNotNull(refrencedRegulationsTagValueItems); List<JudgmentReferencedRegulation> referencedRegulations = Lists.newArrayList(); for (ReferencedRegulationsTagValueItem referencedRegulationsTagValueItem : refrencedRegulationsTagValueItems) { referencedRegulations.add(convert(referencedRegulationsTagValueItem)); } return referencedRegulations; } }
ReferencedRegulationsTagValueConverter implements EnrichmentTagValueConverter<ReferencedRegulationsTagValueItem[], List<JudgmentReferencedRegulation>> { @Override public List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems) { Preconditions.checkNotNull(refrencedRegulationsTagValueItems); List<JudgmentReferencedRegulation> referencedRegulations = Lists.newArrayList(); for (ReferencedRegulationsTagValueItem referencedRegulationsTagValueItem : refrencedRegulationsTagValueItems) { referencedRegulations.add(convert(referencedRegulationsTagValueItem)); } return referencedRegulations; }  }
ReferencedRegulationsTagValueConverter implements EnrichmentTagValueConverter<ReferencedRegulationsTagValueItem[], List<JudgmentReferencedRegulation>> { @Override public List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems) { Preconditions.checkNotNull(refrencedRegulationsTagValueItems); List<JudgmentReferencedRegulation> referencedRegulations = Lists.newArrayList(); for (ReferencedRegulationsTagValueItem referencedRegulationsTagValueItem : refrencedRegulationsTagValueItems) { referencedRegulations.add(convert(referencedRegulationsTagValueItem)); } return referencedRegulations; }  @Override List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems); @Autowired void setLawJournalEntryRepository(
            LawJournalEntryRepository lawJournalEntryRepository); }
ReferencedRegulationsTagValueConverter implements EnrichmentTagValueConverter<ReferencedRegulationsTagValueItem[], List<JudgmentReferencedRegulation>> { @Override public List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems) { Preconditions.checkNotNull(refrencedRegulationsTagValueItems); List<JudgmentReferencedRegulation> referencedRegulations = Lists.newArrayList(); for (ReferencedRegulationsTagValueItem referencedRegulationsTagValueItem : refrencedRegulationsTagValueItems) { referencedRegulations.add(convert(referencedRegulationsTagValueItem)); } return referencedRegulations; }  @Override List<JudgmentReferencedRegulation> convert(ReferencedRegulationsTagValueItem[] refrencedRegulationsTagValueItems); @Autowired void setLawJournalEntryRepository(
            LawJournalEntryRepository lawJournalEntryRepository);  }