Search in sources :

Example 16 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class OcdsControllerTest method ocdsPackageByOcid.

@Test
public void ocdsPackageByOcid() throws Exception {
    final ReleasePackage releasePackage = ocdsController.ocdsPackageByOcid("ocds-endpoint-001");
    Assert.assertNotNull(releasePackage);
    final Optional<Release> release = releasePackage.getReleases().stream().findFirst();
    Assert.assertEquals(true, release.isPresent());
    Assert.assertEquals("ocds-endpoint-001", release.get().getOcid());
}
Also used : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test)

Example 17 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn 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, false);
    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", "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 18 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn 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, false);
    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", "USD", release.getPlanning().getBudget().getAmount().getCurrency());
}
Also used : Release(org.devgateway.ocds.persistence.mongo.Release) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 19 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn 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, false);
    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", "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 20 with Release

use of org.devgateway.ocds.persistence.mongo.Release in project ocvn by devgateway.

the class RecordRepositoryTest method getRelease2.

private Release getRelease2() {
    final Release release = new Release();
    release.setOcid(ocid);
    final Planning planning = new Planning();
    release.setPlanning(planning);
    final Budget budget = new Budget();
    planning.setBudget(budget);
    final Amount amount = new Amount();
    amount.setAmount(BigDecimal.valueOf(2345));
    amount.setCurrency("USD");
    budget.setAmount(amount);
    budget.setDescription("Some description 2");
    budget.setProject("A nice project! 2");
    budget.setSource("The source! 2");
    final Award award1 = new Award();
    award1.setDescription("SoMe AwArD 2");
    award1.setId("2");
    release.getAwards().add(award1);
    final Award award2 = new Award();
    award2.setDescription("Some award3");
    award2.setId("3");
    release.getAwards().add(award2);
    return release;
}
Also used : Award(org.devgateway.ocds.persistence.mongo.Award) Amount(org.devgateway.ocds.persistence.mongo.Amount) Budget(org.devgateway.ocds.persistence.mongo.Budget) Planning(org.devgateway.ocds.persistence.mongo.Planning) Release(org.devgateway.ocds.persistence.mongo.Release)

Aggregations

Release (org.devgateway.ocds.persistence.mongo.Release)38 Test (org.junit.Test)23 File (java.io.File)12 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)10 Amount (org.devgateway.ocds.persistence.mongo.Amount)7 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)4 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)4 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)4 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)4 VNPlanning (org.devgateway.ocvn.persistence.mongo.dao.VNPlanning)4 VNTender (org.devgateway.ocvn.persistence.mongo.dao.VNTender)4 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 BigDecimal (java.math.BigDecimal)3 Award (org.devgateway.ocds.persistence.mongo.Award)3 Budget (org.devgateway.ocds.persistence.mongo.Budget)3 Organization (org.devgateway.ocds.persistence.mongo.Organization)3 JsonView (com.fasterxml.jackson.annotation.JsonView)2