Search in sources :

Example 21 with Process

use of org.openlca.core.model.Process in project olca-modules by GreenDelta.

the class ProcessTest method createProcess.

private Process createProcess(Flow product, ProcessDao dao) {
    Process p = new Process();
    p.name = "process";
    p.refId = UUID.randomUUID().toString();
    Exchange out = createExchange(p, product, null);
    out.isInput = false;
    p.exchanges.add(out);
    p.quantitativeReference = out;
    return dao.insert(p);
}
Also used : Exchange(org.openlca.core.model.Exchange) Process(org.openlca.core.model.Process)

Example 22 with Process

use of org.openlca.core.model.Process 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());
}
Also used : IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) Process(org.openlca.core.model.Process) AbstractZipTest(org.openlca.jsonld.AbstractZipTest) Test(org.junit.Test)

Example 23 with Process

use of org.openlca.core.model.Process in project olca-modules by GreenDelta.

the class ExchangeCostTest method checkImport.

private void checkImport(Process originalProc) {
    Process importedProc = processDao.getForRefId(originalProc.refId);
    Exchange original = originalProc.exchanges.get(0);
    Exchange imported = importedProc.exchanges.get(0);
    Assert.assertEquals(original.costs, imported.costs);
}
Also used : Exchange(org.openlca.core.model.Exchange) Process(org.openlca.core.model.Process)

Example 24 with Process

use of org.openlca.core.model.Process in project olca-modules by GreenDelta.

the class ParameterReferencesTest method createProcess.

private Process createProcess(Exchange[] exchanges, Parameter[] parameters) {
    Process p = new Process();
    p.refId = UUID.randomUUID().toString();
    if (parameters != null)
        p.parameters.addAll(Arrays.asList(parameters));
    if (exchanges != null)
        p.exchanges.addAll(Arrays.asList(exchanges));
    return p;
}
Also used : Process(org.openlca.core.model.Process)

Example 25 with Process

use of org.openlca.core.model.Process 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());
}
Also used : IDatabase(org.openlca.core.database.IDatabase) ProcessDao(org.openlca.core.database.ProcessDao) ProcessDescriptor(org.openlca.core.model.descriptors.ProcessDescriptor) Process(org.openlca.core.model.Process) Location(org.openlca.core.model.Location) Test(org.junit.Test)

Aggregations

Process (org.openlca.core.model.Process)103 Test (org.junit.Test)35 ProcessDao (org.openlca.core.database.ProcessDao)27 Exchange (org.openlca.core.model.Exchange)20 TestProcess (org.openlca.core.TestProcess)15 ProductSystem (org.openlca.core.model.ProductSystem)14 Flow (org.openlca.core.model.Flow)13 Parameter (org.openlca.core.model.Parameter)13 Before (org.junit.Before)9 IDatabase (org.openlca.core.database.IDatabase)9 ProcessDocumentation (org.openlca.core.model.ProcessDocumentation)9 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)9 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)8 AllocationMethod (org.openlca.core.model.AllocationMethod)6 FlowProperty (org.openlca.core.model.FlowProperty)6 ImpactMethod (org.openlca.core.model.ImpactMethod)6 Location (org.openlca.core.model.Location)6 File (java.io.File)5 UnitGroup (org.openlca.core.model.UnitGroup)5 FullResult (org.openlca.core.results.FullResult)5