use of org.openlca.core.database.ProcessDao 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.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ProcessTest method testProcess.
@Test
public void testProcess() throws Exception {
ProcessDao dao = new ProcessDao(db);
Process process = createSimpleModel(dao);
doExport(process);
dao.delete(process);
doImport();
assertTestProcess(process, dao);
delete(process, Tests.getDb());
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ProcessTest method testCyclicProvider.
@Test
public void testCyclicProvider() {
IDatabase db = Tests.getDb();
ProcessDao dao = new ProcessDao(db);
Process[] processes = createCyclicModel(db);
doExport(processes[0]);
dao.delete(processes[0]);
dao.delete(processes[1]);
doImport();
assertTestCyclicProvider(processes, dao);
delete(processes[0], Tests.getDb());
delete(processes[1], Tests.getDb());
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class ProcessesTest method testFindForLabel.
@Test
public void testFindForLabel() {
IDatabase db = Tests.getDb();
Supplier<ProcessDescriptor> query = () -> Processes.findForLabel(db, "cow milking - CH");
assertNull(query.get());
ProcessDao dao = new ProcessDao(db);
Process p1 = new Process();
p1.name = "cow milking";
dao.insert(p1);
assertEquals(p1.id, query.get().id);
Location loc = new Location();
loc.code = "CH";
Daos.base(db, Location.class).insert(loc);
Process p2 = new Process();
p2.name = "cow milking";
p2.location = loc;
dao.insert(p2);
assertEquals(p2.id, query.get().id);
Daos.base(db, Location.class).delete(loc);
for (Process p : dao.getForName("cow milking")) {
dao.delete(p);
}
assertNull(query.get());
}
use of org.openlca.core.database.ProcessDao in project olca-modules by GreenDelta.
the class FormulaInterpreterTest method setUp.
/**
* sets the following parameters:
*
* fi_tests_global = 32
*
* fi_tests_local = fi_tests_global + 10
*/
@Before
public void setUp() {
globalParam = new Parameter();
globalParam.name = "fi_tests_global";
globalParam.isInputParameter = true;
globalParam.scope = ParameterScope.GLOBAL;
globalParam.value = 32;
new ParameterDao(db).insert(globalParam);
process = new Process();
var localParam = new Parameter();
localParam.name = "fi_tests_local";
localParam.formula = "fi_tests_global + 10";
localParam.isInputParameter = false;
localParam.scope = ParameterScope.PROCESS;
process.parameters.add(localParam);
process = new ProcessDao(db).insert(process);
interpreter = ParameterTable.interpreter(db, Collections.singleton(process.id), Collections.emptySet());
}
Aggregations