@@ -0,0 +1,2108 @@
+package org.openlca.core.matrix;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport java.util.List;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.openlca.core.Tests;%0Aimport org.openlca.core.database.IDatabase;%0Aimport org.openlca.core.matrix.index.EnviFlow;%0Aimport org.openlca.core.matrix.index.EnviIndex;%0Aimport org.openlca.core.matrix.index.ImpactIndex;%0Aimport org.openlca.core.model.Direction;%0Aimport org.openlca.core.model.Flow;%0Aimport org.openlca.core.model.FlowProperty;%0Aimport org.openlca.core.model.ImpactCategory;%0Aimport org.openlca.core.model.UnitGroup;%0Aimport org.openlca.core.model.descriptors.Descriptor;%0A%0Apublic class ImpactDirectionTest %7B%0A%0A%09private final IDatabase db = Tests.getDb();%0A%09private Flow flow;%0A%09private ImpactCategory impact;%0A%0A%09@Before%0A%09public void setup() %7B%0A%09%09var units = db.insert(UnitGroup.of(%22Mass units%22, %22kg%22));%0A%09%09var mass = db.insert(FlowProperty.of(%22Mass%22, units));%0A%09%09flow = db.insert(Flow.elementary(%22f%22, mass));%0A%09%09impact = ImpactCategory.of(%22i%22);%0A%09%09impact.factor(flow, 42);%0A%09%09impact = db.insert(impact);%0A%09%7D%0A%0A%09@After%0A%09public void cleanup() %7B%0A%09%09var mass = flow.referenceFlowProperty;%0A%09%09var units = mass.unitGroup;%0A%09%09db.delete(impact, flow, mass, units);%0A%09%7D%0A%0A%09@Test%0A%09public void testMatrixValues() %7B%0A%09%09var i = Direction.INPUT;%0A%09%09var o = Direction.OUTPUT;%0A%09%09Direction x = null;%0A%09%09double pos = 42;%0A%09%09double neg = -42;%0A%0A%09%09checkMatrix(i, x, neg);%0A%09%09checkMatrix(o, x, pos);%0A%09%09checkMatrix(i, i, neg);%0A%09%09checkMatrix(o, i, neg);%0A%09%09checkMatrix(i, o, pos);%0A%09%09checkMatrix(o, o, pos);%0A%09%7D%0A%0A%09private void checkMatrix(%0A%09%09Direction flowDir, Direction impactDir, double expected) %7B%0A%0A%09%09var enviFlow = flowDir == Direction.INPUT%0A%09%09%09? EnviFlow.inputOf(Descriptor.of(flow))%0A%09%09%09: EnviFlow.outputOf(Descriptor.of(flow));%0A%09%09var enviIdx = EnviIndex.create();%0A%09%09enviIdx.add(enviFlow);%0A%09%09impact.direction = impactDir;%0A%09%09impact = db.update(impact);%0A%0A%09%09var impactIdx = ImpactIndex.of(%0A%09%09%09List.of(Descriptor.of(impact)));%0A%09%09var matrix = ImpactBuilder.of(db, enviIdx)%0A%09%09%09.withImpacts(impactIdx)%0A%09%09%09.build().impactMatrix;%0A%09%09assertEquals(expected, matrix.get(0, 0), 1e-10);%0A%09%7D%0A%7D%0A

add failing ImpactDirectionTest