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,
                                    final Boolean mapDeserializer);  ReleasePackageJsonImport(final ReleaseRepository releaseRepository,
                                    final File file,
                                    final Boolean mapDeserializer); @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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-03-tenderAmendment"); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertArrayEquals(new Tender.SubmissionMethod[] {Tender.SubmissionMethod.electronicSubmission}, 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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-04-award"); 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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-05-contract"); 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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-06-implementation"); 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("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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-01-planning"); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertEquals("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, false); final Collection<Release> releases = releasePackageJsonImport.importObjects(); final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-02-tender"); Assert.assertEquals(1, releases.size()); Assert.assertNotNull(importedRelease); Assert.assertEquals(Tender.ProcurementMethod.open, importedRelease.getTender().getProcurementMethod()); }