use of org.openlca.jsonld.input.JsonImport in project olca-modules by GreenDelta.
the class SourceTest method doImport.
private void doImport(SourceDao dao, Source source) {
with(zip -> {
JsonImport jImport = new JsonImport(zip, Tests.getDb());
jImport.run();
});
Assert.assertTrue(dao.contains(source.refId));
Source clone = dao.getForRefId(source.refId);
Assert.assertEquals(source.name, clone.name);
}
use of org.openlca.jsonld.input.JsonImport in project olca-modules by GreenDelta.
the class UnitGroupTest method doImport.
private void doImport(UnitGroupDao dao, UnitGroup group) {
with(zip -> {
JsonImport jImport = new JsonImport(zip, Tests.getDb());
jImport.run();
});
Assert.assertTrue(dao.contains(group.refId));
UnitGroup clone = dao.getForRefId(group.refId);
Assert.assertEquals(group.name, clone.name);
}
use of org.openlca.jsonld.input.JsonImport in project olca-modules by GreenDelta.
the class ParameterTest method testProcess.
@Test
public void testProcess() {
var process = new Process();
process.refId = UUID.randomUUID().toString();
var param = process.parameter("param", 42);
var dao = new ProcessDao(Tests.getDb());
dao.insert(process);
with(zip -> {
JsonExport export = new JsonExport(Tests.getDb(), zip);
export.write(process);
});
dao.delete(process);
with(zip -> {
JsonImport jImport = new JsonImport(zip, Tests.getDb());
jImport.run();
});
var clone = dao.getForRefId(process.refId);
Assert.assertEquals(param.refId, clone.parameters.get(0).refId);
}
use of org.openlca.jsonld.input.JsonImport in project olca-modules by GreenDelta.
the class ParameterTest method testGlobal.
@Test
public void testGlobal() {
var param = Parameter.global("param", "1+1");
var dao = new ParameterDao(Tests.getDb());
dao.insert(param);
with(zip -> {
JsonExport export = new JsonExport(Tests.getDb(), zip);
export.write(param);
});
dao.delete(param);
Assert.assertFalse(dao.contains(param.refId));
with(zip -> {
JsonImport jImport = new JsonImport(zip, Tests.getDb());
jImport.run();
});
Assert.assertTrue(dao.contains(param.refId));
dao.delete(param);
}
use of org.openlca.jsonld.input.JsonImport 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);
}
Aggregations