ReleasePackageJsonImport implements JsonImportPackage<ReleasePackage, Release> { @Override public Collection<Release> importObjects() throws IOException { final ReleasePackage releasePackage = (ReleasePackage) releasePackageJsonToObject.toObject(); final Collection<Release> savedReleases = new LinkedHashSet<>(); if (!releasePackage.getReleases().isEmpty()) { Set<Release> releases = releasePackage.getReleases(); for (Release release : releases) { Release savedRelease = releaseRepository.save(release); savedReleases.add(savedRelease); } } return savedReleases; } ReleasePackageJsonImport(final ReleaseRepository releaseRepository,
                                    final String releasePackageJsonToObject);  ReleasePackageJsonImport(final ReleaseRepository releaseRepository, final File file); @Override Collection<Release> importObjects(); @Override void logMessage(final String message);  }
@Test public void importObjectsTenderAmendment() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader .getResource("json/fictional-example/ocds-213czf-000-00001-03-tenderAmendment.json").getFile()); final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-03-tenderAmendment").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertArrayEquals(new String[] {Tender.SubmissionMethod.electronicSubmission.toString()}, importedRelease.getTender().getSubmissionMethod().toArray()); }
@Test public void importObjectsAward() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-04-award.json") .getFile()); final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-04-award").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); final Set<Award> awards = importedRelease.getAwards(); Assert.assertEquals(Award.Status.pending, awards.iterator().next().getStatus()); }
@Test public void importObjectsContract() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader .getResource("json/fictional-example/ocds-213czf-000-00001-05-contract.json").getFile()); final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-05-contract").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); final Set<Contract> contracts = importedRelease.getContracts(); Assert.assertEquals(Contract.Status.active, contracts.iterator().next().getStatus()); }
@Test public void importObjectsImplementation() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader .getResource("json/fictional-example/ocds-213czf-000-00001-06-implementation.json").getFile()); final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-06-implementation").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertArrayEquals(new Tag[] {Tag.implementation}, importedRelease.getTag().toArray()); final Set<Contract> contracts = importedRelease.getContracts(); final Set<Transaction> transactions = contracts.iterator().next().getImplementation().getTransactions(); Assert.assertEquals(new URI("https: }
@Test public void importObjectsPlanning() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader .getResource("json/fictional-example/ocds-213czf-000-00001-01-planning.json").getFile()); final JsonImportPackage releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-01-planning").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertEquals(Amount.Currency.GBP, importedRelease.getPlanning().getBudget().getAmount().getCurrency()); }
@Test public void importObjectsTender() throws Exception { final ClassLoader classLoader = getClass().getClassLoader(); final File file = new File(classLoader .getResource("json/fictional-example/ocds-213czf-000-00001-02-tender.json").getFile()); final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-02-tender").get(); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertEquals(Tender.ProcurementMethod.open, importedRelease.getTender().getProcurementMethod()); }