use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleasePackageJsonImportTest method importObjectsTenderAmendment.
@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");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
Assert.assertArrayEquals(new String[] { Tender.SubmissionMethod.electronicSubmission.toString() }, importedRelease.getTender().getSubmissionMethod().toArray());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleasePackageJsonImportTest method importObjectsContract.
@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");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
final Set<Contract> contracts = importedRelease.getContracts();
Assert.assertEquals(Contract.Status.active, contracts.iterator().next().getStatus());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleasePackageJsonImportTest method importObjectsPlanning.
@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");
Assert.assertEquals(1, releases.size());
Assert.assertNotNull(importedRelease);
Assert.assertEquals(Amount.Currency.GBP, importedRelease.getPlanning().getBudget().getAmount().getCurrency());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleaseJsonToObjectTest method toObjectFromFile.
@Test
public void toObjectFromFile() throws Exception {
final ClassLoader classLoader = getClass().getClassLoader();
final File file = new File(classLoader.getResource("json/release-json-to-object-test.json").getFile());
final JsonToObject releaseJsonToObject = new ReleaseJsonToObject(file);
Assert.assertTrue("Object is a Release", releaseJsonToObject.toObject() instanceof Release);
final Release release = (Release) releaseJsonToObject.toObject();
Assert.assertEquals("IDs are the same", "12345", release.getId());
Assert.assertEquals("Check budget amount", new BigDecimal(10000), release.getPlanning().getBudget().getAmount().getAmount());
Assert.assertEquals("Check budget currency", Amount.Currency.RON, release.getPlanning().getBudget().getAmount().getCurrency());
}
use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.
the class ReleaseJsonToObjectTest method toObject.
@Test
public void toObject() throws Exception {
final String jsonRelease = "{\n" + " id: \"123\",\n" + " tag: [\"tender\"],\n" + " planning: {\n" + " budget: {\n" + " description: \"budget desc...\",\n" + " amount: {\n" + " amount: 10000,\n" + " currency: \"USD\"\n" + " }\n" + " }\n" + " }\n" + "}";
final JsonToObject releaseJsonToObject = new ReleaseJsonToObject(jsonRelease);
Assert.assertTrue("Object is a Release", releaseJsonToObject.toObject() instanceof Release);
final Release release = (Release) releaseJsonToObject.toObject();
Assert.assertEquals("IDs are the same", "123", release.getId());
Assert.assertEquals("Check budget amount", new BigDecimal(10000), release.getPlanning().getBudget().getAmount().getAmount());
Assert.assertEquals("Check budget currency", Amount.Currency.USD, release.getPlanning().getBudget().getAmount().getCurrency());
}
Aggregations