Search in sources :

Example 6 with ReleasePackage

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

the class OcdsControllerTest method ocdsPackages.

@Test
public void ocdsPackages() throws Exception {
    final List<ReleasePackage> releasePackages = ocdsController.ocdsPackages(new YearFilterPagingRequest());
    Assert.assertEquals(3, releasePackages.size());
}
Also used : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Test(org.junit.Test)

Example 7 with ReleasePackage

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

the class OcdsControllerTest method packagedReleaseByProjectId.

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

Example 8 with ReleasePackage

use of org.devgateway.ocds.persistence.mongo.ReleasePackage 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 9 with ReleasePackage

use of org.devgateway.ocds.persistence.mongo.ReleasePackage 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)

Aggregations

ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)9 Release (org.devgateway.ocds.persistence.mongo.Release)6 Test (org.junit.Test)6 JsonView (com.fasterxml.jackson.annotation.JsonView)1 ApiOperation (io.swagger.annotations.ApiOperation)1 File (java.io.File)1 BigDecimal (java.math.BigDecimal)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1 Publisher (org.devgateway.ocds.persistence.mongo.Publisher)1 JsonToObject (org.devgateway.ocds.persistence.mongo.spring.json2object.JsonToObject)1 ReleasePackageJsonToObject (org.devgateway.ocds.persistence.mongo.spring.json2object.ReleasePackageJsonToObject)1 YearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1