Search in sources :

Example 6 with JsonExport

use of org.openlca.jsonld.output.JsonExport in project olca-modules by GreenDelta.

the class ParameterTest method testImpactCategory.

@Test
public void testImpactCategory() {
    var impact = new ImpactCategory();
    impact.refId = UUID.randomUUID().toString();
    var param = impact.parameter("param", 42);
    var dao = new ImpactCategoryDao(Tests.getDb());
    dao.insert(impact);
    with(zip -> {
        JsonExport export = new JsonExport(Tests.getDb(), zip);
        export.write(impact);
    });
    dao.delete(impact);
    with(zip -> {
        JsonImport jImport = new JsonImport(zip, Tests.getDb());
        jImport.run();
    });
    ImpactCategory clone = dao.getForRefId(impact.refId);
    Assert.assertEquals(param.refId, clone.parameters.get(0).refId);
}
Also used : JsonImport(org.openlca.jsonld.input.JsonImport) ImpactCategory(org.openlca.core.model.ImpactCategory) JsonExport(org.openlca.jsonld.output.JsonExport) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 7 with JsonExport

use of org.openlca.jsonld.output.JsonExport in project olca-modules by GreenDelta.

the class SocialIndicatorTest method doExport.

private void doExport(SocialIndicator indicator, SocialIndicatorDao dao) {
    with(zip -> {
        JsonExport export = new JsonExport(Tests.getDb(), zip);
        export.write(indicator);
    });
    dao.delete(indicator);
    Assert.assertFalse(dao.contains(indicator.refId));
}
Also used : JsonExport(org.openlca.jsonld.output.JsonExport)

Example 8 with JsonExport

use of org.openlca.jsonld.output.JsonExport in project olca-modules by GreenDelta.

the class SourceTest method doExport.

private void doExport(Source source, SourceDao dao) {
    with(zip -> {
        JsonExport export = new JsonExport(Tests.getDb(), zip);
        export.write(source);
    });
    dao.delete(source);
    Assert.assertFalse(dao.contains(source.refId));
}
Also used : JsonExport(org.openlca.jsonld.output.JsonExport)

Example 9 with JsonExport

use of org.openlca.jsonld.output.JsonExport in project olca-modules by GreenDelta.

the class UnitGroupTest method doExport.

private void doExport(UnitGroup group, UnitGroupDao dao) {
    with(zip -> {
        JsonExport export = new JsonExport(Tests.getDb(), zip);
        export.write(group);
    });
    dao.delete(group);
    Assert.assertFalse(dao.contains(group.refId));
}
Also used : JsonExport(org.openlca.jsonld.output.JsonExport)

Example 10 with JsonExport

use of org.openlca.jsonld.output.JsonExport in project olca-modules by GreenDelta.

the class ActorTest method doExport.

private void doExport(Actor actor, ActorDao dao) {
    with(zip -> {
        JsonExport export = new JsonExport(Tests.getDb(), zip);
        export.write(actor);
    });
    dao.delete(actor);
    Assert.assertFalse(dao.contains(actor.refId));
}
Also used : JsonExport(org.openlca.jsonld.output.JsonExport)

Aggregations

JsonExport (org.openlca.jsonld.output.JsonExport)25 Test (org.junit.Test)13 JsonImport (org.openlca.jsonld.input.JsonImport)7 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)6 File (java.io.File)4 MemStore (org.openlca.jsonld.MemStore)3 Parameter (org.openlca.core.model.Parameter)2 Process (org.openlca.core.model.Process)2 ProductSystem (org.openlca.core.model.ProductSystem)2 Rpc (org.openlca.ipc.Rpc)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ParameterDao (org.openlca.core.database.ParameterDao)1 ProcessDao (org.openlca.core.database.ProcessDao)1 ProductSystemDao (org.openlca.core.database.ProductSystemDao)1 Currency (org.openlca.core.model.Currency)1