use of org.openlca.core.model.descriptors.Descriptor in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method testFindInImpactCategory.
@Test
public void testFindInImpactCategory() {
ImpactFactor iFactor = new ImpactFactor();
iFactor.flow = flow;
iFactor.flowPropertyFactor = factor;
ImpactCategory category = new ImpactCategory();
category.impactFactors.add(iFactor);
ImpactCategoryDao dao = new ImpactCategoryDao(database);
dao.insert(category);
List<RootDescriptor> results = search.findUses(factor);
dao.delete(category);
Assert.assertEquals(1, results.size());
Descriptor expected = Descriptor.of(category);
Assert.assertEquals(expected, results.get(0));
}
use of org.openlca.core.model.descriptors.Descriptor in project olca-modules by GreenDelta.
the class FlowPropertyFactorUseSearchTest method testFindInProcesses.
@Test
public void testFindInProcesses() {
Process process = createProcess();
List<RootDescriptor> results = search.findUses(factor);
new ProcessDao(database).delete(process);
Descriptor expected = Descriptor.of(process);
Assert.assertEquals(1, results.size());
Assert.assertEquals(expected, results.get(0));
}
use of org.openlca.core.model.descriptors.Descriptor in project olca-modules by GreenDelta.
the class RefEntityDaoTest method testGetDescriptorsForCategory.
private <T extends RootEntity, V extends RootDescriptor> void testGetDescriptorsForCategory(RootEntityDao<T, V> dao, T instance, Category category) {
List<V> descriptors = dao.getDescriptors(Optional.ofNullable(category));
Descriptor descriptor = ListUtils.findDescriptor(instance.id, descriptors);
Assert.assertNotNull(descriptor);
new CategoryDao(Tests.getDb()).delete(category);
}
use of org.openlca.core.model.descriptors.Descriptor in project olca-modules by GreenDelta.
the class RefEntityDaoTest method testFindForNullCategory.
private <T extends RootEntity, V extends RootDescriptor> void testFindForNullCategory(RootEntityDao<T, V> dao, T instance) {
List<V> descriptors = dao.getDescriptors(Optional.empty());
Descriptor descriptor = ListUtils.findDescriptor(instance.id, descriptors);
Assert.assertNotNull(descriptor);
}
use of org.openlca.core.model.descriptors.Descriptor in project olca-modules by GreenDelta.
the class DescriptorsTest method testToDescriptor.
@Test
public void testToDescriptor() throws Exception {
for (ModelType t : ModelType.values()) {
Class<? extends RefEntity> clazz = t.modelClass;
if (clazz == null)
continue;
RefEntity e = clazz.newInstance();
e.name = t.name();
e.refId = t.name();
Descriptor d = Descriptor.of(e);
assertEquals(t, d.type);
assertEquals(e.name, d.name);
assertEquals(e.refId, d.refId);
}
}
Aggregations