use of org.openlca.core.model.Category in project olca-modules by GreenDelta.
the class ProductSystemReferenceSearchTest method createModel.
@Override
protected ProductSystem createModel() {
ProductSystem system = new ProductSystem();
system.category = insertAndAddExpected("category", new Category());
system.referenceProcess = createProcess();
system.referenceExchange = system.referenceProcess.exchanges.get(0);
system.targetFlowPropertyFactor = system.referenceExchange.flowPropertyFactor;
system.targetUnit = system.targetFlowPropertyFactor.flowProperty.unitGroup.units.get(0);
system.processes.add(system.referenceProcess.id);
Process p1 = insertAndAddExpected("processes", new Process());
Process p2 = insertAndAddExpected("processes", new Process());
Process p3 = insertAndAddExpected("processes", new Process());
system.processes.add(p1.id);
system.processes.add(p2.id);
system.processes.add(p3.id);
system.processLinks.add(createLink(p1, p2));
system.processLinks.add(createLink(p2, p3));
String n1 = generateName();
String n2 = generateName();
String n3 = generateName();
// TODO: find parameter references
// system.parameterRedefs.add(createParameterRedef(n1, p1.id));
// formula with parameter to see if added as reference (unexpected)
// system.parameterRedefs.add(createParameterRedef(n2, n3 + "*5"));
Parameter globalUnreferenced = createParameter(n1, "3*3", true);
Parameter globalUnreferenced2 = createParameter(n3, "3*3", true);
// must be inserted manually
globalUnreferenced = db.insert(globalUnreferenced);
globalUnreferenced2 = db.insert(globalUnreferenced2);
return db.insert(system);
}
use of org.openlca.core.model.Category in project olca-modules by GreenDelta.
the class CurrencyReferenceSearchTest method createModel.
@Override
protected Currency createModel() {
Currency currency = new Currency();
currency.category = insertAndAddExpected("category", new Category());
currency.referenceCurrency = insertAndAddExpected("referenceCurrency", new Currency());
currency = db.insert(currency);
currencies.add(currency);
return currency;
}
use of org.openlca.core.model.Category in project olca-modules by GreenDelta.
the class UnitGroupReferenceSearchTest method createModel.
@Override
protected UnitGroup createModel() {
UnitGroup group = new UnitGroup();
group.category = insertAndAddExpected("category", new Category());
group.defaultFlowProperty = insertAndAddExpected("defaultFlowProperty", new FlowProperty());
return db.insert(group);
}
use of org.openlca.core.model.Category in project olca-modules by GreenDelta.
the class RefEntityDaoTest method addCategory.
private <T extends RootEntity, V extends RootDescriptor> Category addCategory(Class<T> clazz, RootEntityDao<T, V> dao, T instance) {
Category category = new Category();
category.refId = UUID.randomUUID().toString();
category.name = "test_category";
category.modelType = ModelType.forModelClass(clazz);
CategoryDao catDao = new CategoryDao(Tests.getDb());
catDao.insert(category);
instance.category = category;
dao.update(instance);
return category;
}
use of org.openlca.core.model.Category in project olca-modules by GreenDelta.
the class CategoryDaoTest method testFindRoot.
@Test
public void testFindRoot() {
Category parent = create();
Category child = create();
parent.childCategories.add(child);
child.category = parent;
dao.insert(parent);
Tests.emptyCache();
List<Category> roots = dao.getRootCategories(ModelType.FLOW);
Assert.assertTrue(roots.contains(parent));
Assert.assertFalse(roots.contains(child));
dao.delete(parent);
}
Aggregations