Search in sources :

Example 66 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.

the class ReleasePackageJsonToObjectTest method toObject.

@Test
public void toObject() throws Exception {
    final String jsonReleasePackage = "{\n" + "    \"uri\": " + "\"http://standard.open-contracting.org/examples/releases/ocds-213czf-000-00001-01-planning.json\",\n" + "    \"publishedDate\": \"2009-03-15T14:45:00Z\",\n" + "    \"publisher\": {\n" + "        \"scheme\": \"GB-COH\",\n" + "        \"uid\": \"09506232\",\n" + "        \"name\": \"Open Data Services Co-operative Limited\",\n" + "        \"uri\": \"http://standard.open-contracting.org/examples/\"\n" + "    },\n" + "    \"license\": \"http://opendatacommons.org/licenses/pddl/1.0/\",\n" + "    \"publicationPolicy\": \"https://github.com/open-contracting/sample-data/\",\n" + "    \"releases\":[{\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" + "    }]\n" + "}";
    final JsonToObject releasePackageJsonToObject = new ReleasePackageJsonToObject(jsonReleasePackage);
    Assert.assertTrue("Object is a ReleasePackage", releasePackageJsonToObject.toObject() instanceof ReleasePackage);
    final ReleasePackage releasePackage = (ReleasePackage) releasePackageJsonToObject.toObject();
    Assert.assertEquals("Publisher uid are the same", "09506232", releasePackage.getPublisher().getUid());
    Assert.assertEquals("Check published date", new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:sszzzz").parse("2009-03-15T14:45:00-0000"), releasePackage.getPublishedDate());
    Assert.assertFalse("Release array is not empty", releasePackage.getReleases().isEmpty());
    final Release release = releasePackage.getReleases().iterator().next();
    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 : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) SimpleDateFormat(java.text.SimpleDateFormat) Release(org.devgateway.ocds.persistence.mongo.Release) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 67 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.

the class RecordRepositoryTest method testReleaseSaveAndFind.

@Test
public void testReleaseSaveAndFind() {
    final Release release = new Release();
    release.setOcid(ocid);
    releaseRepository.insert(release);
    final Release byOcid = releaseRepository.findByOcid(ocid);
    Assert.assertEquals(ocid, byOcid.getOcid());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)

Example 68 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project oc-explorer by devgateway.

the class ReleaseRepositoryTest method testReleaseSaveAndFind.

@Test
public void testReleaseSaveAndFind() {
    final Release release = new Release();
    release.setOcid(ocid);
    releaseRepository.insert(release);
    final Release byOcid = releaseRepository.findByOcid(ocid);
    Assert.assertEquals(ocid, byOcid.getOcid());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) AbstractMongoTest(org.devgateway.toolkit.persistence.mongo.AbstractMongoTest) 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