Search in sources :

Example 1 with Descriptor

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));
}
Also used : ImpactFactor(org.openlca.core.model.ImpactFactor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) ImpactCategory(org.openlca.core.model.ImpactCategory) ImpactCategoryDao(org.openlca.core.database.ImpactCategoryDao) Test(org.junit.Test)

Example 2 with Descriptor

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));
}
Also used : ProcessDao(org.openlca.core.database.ProcessDao) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor) Process(org.openlca.core.model.Process) Test(org.junit.Test)

Example 3 with Descriptor

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);
}
Also used : Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Example 4 with Descriptor

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);
}
Also used : Descriptor(org.openlca.core.model.descriptors.Descriptor) RootDescriptor(org.openlca.core.model.descriptors.RootDescriptor)

Example 5 with 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);
    }
}
Also used : Descriptor(org.openlca.core.model.descriptors.Descriptor) Test(org.junit.Test)

Aggregations

Descriptor (org.openlca.core.model.descriptors.Descriptor)10 RootDescriptor (org.openlca.core.model.descriptors.RootDescriptor)4 Test (org.junit.Test)3 Process (org.openlca.core.model.Process)2 JsonObject (com.google.gson.JsonObject)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 CostResultDescriptor (org.openlca.app.util.CostResultDescriptor)1 ImpactCategoryDao (org.openlca.core.database.ImpactCategoryDao)1 ProcessDao (org.openlca.core.database.ProcessDao)1 EnviFlow (org.openlca.core.matrix.index.EnviFlow)1 FlowType (org.openlca.core.model.FlowType)1 ImpactCategory (org.openlca.core.model.ImpactCategory)1 ImpactFactor (org.openlca.core.model.ImpactFactor)1 Location (org.openlca.core.model.Location)1 RefEntity (org.openlca.core.model.RefEntity)1 FlowDescriptor (org.openlca.core.model.descriptors.FlowDescriptor)1 ImpactDescriptor (org.openlca.core.model.descriptors.ImpactDescriptor)1 ProcessDescriptor (org.openlca.core.model.descriptors.ProcessDescriptor)1