Search in sources :

Example 26 with Release

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());
}
Also used : File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 27 with Release

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());
}
Also used : File(java.io.File) Contract(org.devgateway.ocds.persistence.mongo.Contract) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 28 with Release

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());
}
Also used : File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 29 with Release

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());
}
Also used : File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 30 with Release

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());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Release (org.devgateway.ocds.persistence.mongo.Release)68 Test (org.junit.Test)44 File (java.io.File)22 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)20 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)12 Amount (org.devgateway.ocds.persistence.mongo.Amount)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)6 BigDecimal (java.math.BigDecimal)6 Award (org.devgateway.ocds.persistence.mongo.Award)6 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)6 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)6 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)6 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 Budget (org.devgateway.ocds.persistence.mongo.Budget)5 Contract (org.devgateway.ocds.persistence.mongo.Contract)4 Planning (org.devgateway.ocds.persistence.mongo.Planning)4 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)4 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)4