Package eu.scape_project.planning.model.measurement

Examples of eu.scape_project.planning.model.measurement.Measure


        criteriaManager.init();
    }

    @Test
    public void testRetriveSingleMeasureBasic() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#3");
        Assert.assertNotNull(m);
    }
View Full Code Here


        Assert.assertNotNull(m);
    }

    @Test
    public void testMeasureWithPositiveNumberScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#3");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof PositiveFloatScale);
    }
View Full Code Here

        Assert.assertTrue(s instanceof PositiveFloatScale);
    }

    @Test
    public void testMeasureWithPositiveIntegerScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#96");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof PositiveIntegerScale);
    }
View Full Code Here

        Assert.assertTrue(s instanceof PositiveIntegerScale);
    }

    @Test
    public void testMeasureWithOrdinalScale() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#38");
        Assert.assertNotNull(m);

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);

        Assert.assertTrue(s instanceof OrdinalScale);
        Assert.assertTrue("Measure '" + m.getName() + "' scale " + s.getDisplayName() + " has no restriction defined.",
            StringUtils.isNotEmpty(((OrdinalScale) s).getRestriction()));
    }
View Full Code Here

            StringUtils.isNotEmpty(((OrdinalScale) s).getRestriction()));
    }

    @Test
    public void testRetrievedMeasureIsComplete() {
        Measure m = criteriaManager.getMeasure("http://purl.org/DP/quality/measures#30");
        Assert.assertNotNull(m);
        Assert.assertTrue(StringUtils.isNotEmpty(m.getUri()));
        Assert.assertTrue(StringUtils.isNotEmpty(m.getName()));

        Attribute a = m.getAttribute();
        Assert.assertNotNull(a);
        Assert.assertTrue(StringUtils.isNotEmpty(a.getUri()));
        Assert.assertTrue(StringUtils.isNotEmpty(a.getName()));

        CriterionCategory category = a.getCategory();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no category!", category);
        Assert.assertTrue("Measure '" + m.getName() + "' category has no uri!",
            StringUtils.isNotEmpty(category.getUri()));
        Assert.assertNotNull("Measure '" + m.getName() + "' category " + category.getUri() + " has no scope",
            category.getScope());

        Scale s = m.getScale();
        Assert.assertNotNull("Measure '" + m.getName() + "' has no scale!", s);
        Assert.assertNotNull("Measure '" + m.getName() + "' scale " + s.getDisplayName() + " has no type", s.getType());
    }
View Full Code Here

     */
    @Lock(LockType.READ)
    public List<String> getCategoryHierachy(String measureUri) {
        List<String> hierarchy = new ArrayList<String>();

        Measure m = knownMeasures.get(measureUri);

        if (m == null) {
            return hierarchy;
        }

        Attribute a = knownAttributes.get(m.getAttribute().getUri());

        if (a == null) {
            return hierarchy;
        }

View Full Code Here

            Resource attribute = qs.getResource("a");

            String attributeUri = attribute.toString();

            Measure m = new Measure();

            m.setUri(qs.getResource("m").toString());
            m.setName(qs.getLiteral("mn").getString());
            m.setDescription(qs.getLiteral("md").getString());

            Scale s = createScale(qs.getResource("s").getLocalName());
            m.setScale(s);

            if ((s instanceof RestrictedScale) && (qs.contains("r"))) {
                String restriction = qs.getLiteral("r").getString();
                ((RestrictedScale) s).setRestriction(restriction);
            }

            Attribute a = knownAttributes.get(attributeUri);

            m.setAttribute(a);

            if ((a != null) && (s != null)) {
                // only add completely defined measures
                knownMeasures.put(m.getUri(), m);
            }
        }
    }
View Full Code Here

        when(plan1.getOverallResults()).thenReturn(plan1ResultNode);
        when(plan1.getWinningAlternative()).thenReturn("alternative3");
        plans.add(plan1);

        // Measures
        Measure m1 = mock(Measure.class);
        when(m1.getUri()).thenReturn("http://measure1");
        Measure m2 = mock(Measure.class);
        when(m2.getUri()).thenReturn("http://measure2");
        Measure m3 = mock(Measure.class);
        when(m3.getUri()).thenReturn("http://measure3");

        // Leaves
        // Leaf1
        VPlanLeaf leaf1 = mock(VPlanLeaf.class);
        when(leaf1.isMapped()).thenReturn(true);
        when(leaf1.getPlanId()).thenReturn(1);
        when(leaf1.getMeasure()).thenReturn(m1);
        when(leaf1.hasKOPotential()).thenReturn(false);
        when(leaf1.getPotentialMinimum()).thenReturn(1d);
        when(leaf1.getPotentialMaximum()).thenReturn(4d);
        when(leaf1.getTotalWeight()).thenReturn(0.1d);
        Map<String, Double> leaf1Results = new HashMap<String, Double>();
        leaf1Results.put("alternative1", 1d);
        leaf1Results.put("alternative2", 2d);
        leaf1Results.put("alternative3", 3d);
        when(leaf1.getAlternativeResultsAsMap()).thenReturn(leaf1Results);

        // Leaf2
        VPlanLeaf leaf2 = mock(VPlanLeaf.class);
        when(leaf2.isMapped()).thenReturn(true);
        when(leaf2.getPlanId()).thenReturn(1);
        when(leaf2.getMeasure()).thenReturn(m2);
        when(leaf2.hasKOPotential()).thenReturn(false);
        when(leaf2.getPotentialMinimum()).thenReturn(1d);
        when(leaf2.getPotentialMaximum()).thenReturn(4d);
        when(leaf2.getTotalWeight()).thenReturn(0.1d);
        Map<String, Double> leaf2Results = new HashMap<String, Double>();
        leaf2Results.put("alternative1", 1d);
        leaf2Results.put("alternative2", 2d);
        leaf2Results.put("alternative3", 3d);
        when(leaf2.getAlternativeResultsAsMap()).thenReturn(leaf2Results);

        // Leaf3
        VPlanLeaf leaf3 = mock(VPlanLeaf.class);
        when(leaf3.isMapped()).thenReturn(true);
        when(leaf3.getPlanId()).thenReturn(1);
        when(leaf3.getMeasure()).thenReturn(m3);
        when(leaf3.hasKOPotential()).thenReturn(false);
        when(leaf3.getPotentialMinimum()).thenReturn(1d);
        when(leaf3.getPotentialMaximum()).thenReturn(4d);
        when(leaf3.getTotalWeight()).thenReturn(0.1d);
        Map<String, Double> leaf3Results = new HashMap<String, Double>();
        leaf3Results.put("alternative1", 1d);
        leaf3Results.put("alternative2", 2d);
        leaf3Results.put("alternative3", 3d);
        when(leaf3.getAlternativeResultsAsMap()).thenReturn(leaf3Results);

        List<VPlanLeaf> leaves = new ArrayList<VPlanLeaf>();
        leaves.add(leaf1);
        leaves.add(leaf2);
        leaves.add(leaf3);

        DominatedSets c = new RankChangingDominatedSets(plans, leaves);

        List<List<String>> rangeChangingSets = c.getDominatedSets(Aggregation.ALL);

        // Assert
        assertEquals(rangeChangingSets.size(), 1);
        List<String> set1 = rangeChangingSets.get(0);
        assertEquals(set1.size(), 3);
        assertTrue(set1.contains(m1.getUri()));
        assertTrue(set1.contains(m2.getUri()));
        assertTrue(set1.contains(m3.getUri()));
    }
View Full Code Here

        when(plan1.getOverallResults()).thenReturn(plan1ResultNode);
        when(plan1.getWinningAlternative()).thenReturn("alternative3");
        plans.add(plan1);

        // Measures
        Measure m1 = mock(Measure.class);
        when(m1.getUri()).thenReturn("http://measure1");
        Measure m2 = mock(Measure.class);
        when(m2.getUri()).thenReturn("http://measure2");

        // Leaves
        // Leaf1
        VPlanLeaf leaf1 = mock(VPlanLeaf.class);
        when(leaf1.isMapped()).thenReturn(true);
        when(leaf1.getPlanId()).thenReturn(1);
        when(leaf1.getMeasure()).thenReturn(m1);
        when(leaf1.hasKOPotential()).thenReturn(true);
        when(leaf1.getPotentialMinimum()).thenReturn(1d);
        when(leaf1.getPotentialMaximum()).thenReturn(4d);
        when(leaf1.getTotalWeight()).thenReturn(0.1d);
        Map<String, Double> leaf1Results = new HashMap<String, Double>();
        leaf1Results.put("alternative1", 1d);
        leaf1Results.put("alternative2", 2d);
        leaf1Results.put("alternative3", 3d);
        when(leaf1.getAlternativeResultsAsMap()).thenReturn(leaf1Results);

        // Leaf2
        VPlanLeaf leaf2 = mock(VPlanLeaf.class);
        when(leaf2.isMapped()).thenReturn(true);
        when(leaf2.getPlanId()).thenReturn(1);
        when(leaf2.getMeasure()).thenReturn(m2);
        when(leaf2.hasKOPotential()).thenReturn(false);
        when(leaf2.getPotentialMinimum()).thenReturn(1d);
        when(leaf2.getPotentialMaximum()).thenReturn(4d);
        when(leaf2.getTotalWeight()).thenReturn(0.1d);
        Map<String, Double> leaf2Results = new HashMap<String, Double>();
        leaf2Results.put("alternative1", 1d);
        leaf2Results.put("alternative2", 2d);
        leaf2Results.put("alternative3", 3d);
        when(leaf2.getAlternativeResultsAsMap()).thenReturn(leaf2Results);

        List<VPlanLeaf> leaves = new ArrayList<VPlanLeaf>();
        leaves.add(leaf1);
        leaves.add(leaf2);

        DominatedSets c = new RankChangingDominatedSets(plans, leaves);

        List<List<String>> rangeChangingSets = c.getDominatedSets(Aggregation.ALL);

        // Assert
        assertEquals(rangeChangingSets.size(), 1);
        List<String> set1 = rangeChangingSets.get(0);
        assertEquals(set1.size(), 1);
        assertTrue(set1.contains(m2.getUri()));
    }
View Full Code Here

        when(plan1.getOverallResults()).thenReturn(plan1ResultNode);
        when(plan1.getWinningAlternative()).thenReturn("alternative3");
        plans.add(plan1);

        // Measures
        Measure m1 = mock(Measure.class);
        when(m1.getUri()).thenReturn("http://measure1");
        Measure m2 = mock(Measure.class);
        when(m2.getUri()).thenReturn("http://measure2");
        Measure m3 = mock(Measure.class);
        when(m3.getUri()).thenReturn("http://measure3");

        // Leaves
        // Leaf1
        VPlanLeaf leaf1 = mock(VPlanLeaf.class);
        when(leaf1.isMapped()).thenReturn(true);
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.model.measurement.Measure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.