Search in sources :

Example 1 with Exchange

use of org.openlca.ilcd.processes.Exchange in project olca-modules by GreenDelta.

the class ExchangeExtensionTest method testEmpty.

@Test
public void testEmpty() {
    Exchange raw = new Exchange();
    raw.id = 1;
    Exchange exchange = io(raw);
    assertTrue(exchange != raw);
    ExchangeExtension extension = new ExchangeExtension(exchange);
    assertNull(extension.getAmount());
    assertNull(extension.getFormula());
    assertNull(extension.getPropertyId());
    assertNull(extension.getUnitId());
    assertFalse(extension.isValid());
}
Also used : Exchange(org.openlca.ilcd.processes.Exchange) ExchangeExtension(org.openlca.ilcd.util.ExchangeExtension) Test(org.junit.Test)

Example 2 with Exchange

use of org.openlca.ilcd.processes.Exchange in project olca-modules by GreenDelta.

the class ExchangeExtensionTest method createExchange.

private Exchange createExchange() {
    Exchange exchange = new Exchange();
    exchange.id = 1;
    exchange.meanAmount = 500;
    ExchangeExtension extension = new ExchangeExtension(exchange);
    extension.setAmount(42);
    extension.setFormula("2 * Pi * sqr(r)");
    extension.setPropertyId("property-id");
    extension.setUnitId("unit-id");
    extension.setDefaultProvider("abc-def");
    extension.setAvoidedProduct(true);
    return exchange;
}
Also used : Exchange(org.openlca.ilcd.processes.Exchange) ExchangeExtension(org.openlca.ilcd.util.ExchangeExtension)

Example 3 with Exchange

use of org.openlca.ilcd.processes.Exchange in project olca-modules by GreenDelta.

the class ProcessReadWriteTest method createExchange.

private void createExchange(Process process) {
    Exchange exchange = new Exchange();
    exchange.meanAmount = 1.5;
    process.exchanges.add(exchange);
}
Also used : Exchange(org.openlca.ilcd.processes.Exchange)

Example 4 with Exchange

use of org.openlca.ilcd.processes.Exchange in project olca-modules by GreenDelta.

the class ProcessSampleTest method testAllocation.

@Test
public void testAllocation() {
    with(p -> {
        Exchange e = p.exchanges.get(0);
        assertEquals(2, e.allocations.length);
        AllocationFactor f = e.allocations[1];
        assertEquals(57.98, f.fraction, 1e-10);
        assertEquals(1, f.productExchangeId);
    });
}
Also used : Exchange(org.openlca.ilcd.processes.Exchange) AllocationFactor(org.openlca.ilcd.processes.AllocationFactor) Test(org.junit.Test)

Example 5 with Exchange

use of org.openlca.ilcd.processes.Exchange in project olca-modules by GreenDelta.

the class AllocationFactors method addCausalFactor.

private void addCausalFactor(AllocationFactor factor) {
    Exchange exchange = exchangeMap.get(factor.exchange);
    if (exchange == null)
        return;
    Exchange product = findProduct(factor);
    if (product == null)
        return;
    addFactor(exchange, factor.value, product.id);
}
Also used : Exchange(org.openlca.ilcd.processes.Exchange)

Aggregations

Exchange (org.openlca.ilcd.processes.Exchange)10 Test (org.junit.Test)3 ExchangeExtension (org.openlca.ilcd.util.ExchangeExtension)2 Other (org.openlca.ilcd.commons.Other)1 Ref (org.openlca.ilcd.commons.Ref)1 ProcessSampleTest (org.openlca.ilcd.io.ProcessSampleTest)1 AllocationFactor (org.openlca.ilcd.processes.AllocationFactor)1 Process (org.openlca.ilcd.processes.Process)1