Search in sources :

Example 1 with Contract

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

the class ReleasePackageJsonImportTest method importObjectsImplementation.

@Test
public void importObjectsImplementation() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/fictional-example/ocds-213czf-000-00001-06-implementation.json").getFile());
    final ReleasePackageJsonImport releasePackageJsonImport = new ReleasePackageJsonImport(releaseRepository, file, false);
    final Collection<Release> releases = releasePackageJsonImport.importObjects();
    final Release importedRelease = releaseRepository.findById("ocds-213czf-000-00001-06-implementation");
    Assert.assertEquals(1, releases.size());
    Assert.assertNotNull(importedRelease);
    Assert.assertArrayEquals(new Tag[] { Tag.implementation }, importedRelease.getTag().toArray());
    final Set<Contract> contracts = importedRelease.getContracts();
    final Set<Transaction> transactions = contracts.iterator().next().getImplementation().getTransactions();
    Assert.assertEquals("https://openspending.org/uk-barnet-spending/", transactions.iterator().next().getSource());
}
Also used : Transaction(org.devgateway.ocds.persistence.mongo.Transaction) 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 2 with Contract

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

Aggregations

File (java.io.File)2 Contract (org.devgateway.ocds.persistence.mongo.Contract)2 Release (org.devgateway.ocds.persistence.mongo.Release)2 AbstractMongoTest (org.devgateway.toolkit.persistence.mongo.AbstractMongoTest)2 Test (org.junit.Test)2 Transaction (org.devgateway.ocds.persistence.mongo.Transaction)1