EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.tcfmoop.tests]

COVERAGE SUMMARY FOR SOURCE FILE [MinimalQualityCriteriaValueCriterionTest.java]

nameclass, %method, %block, %line, %
MinimalQualityCriteriaValueCriterionTest.java0%   (0/2)0%   (0/5)0%   (0/328)0%   (0/59)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class MinimalQualityCriteriaValueCriterionTest0%   (0/1)0%   (0/4)0%   (0/317)0%   (0/56)
MinimalQualityCriteriaValueCriterionTest (): void 0%   (0/1)0%   (0/92)0%   (0/14)
setUp (): void 0%   (0/1)0%   (0/155)0%   (0/28)
testEnoughConformingCandidates (): void 0%   (0/1)0%   (0/41)0%   (0/8)
testNotEnoughConformingCandidates (): void 0%   (0/1)0%   (0/29)0%   (0/6)
     
class MinimalQualityCriteriaValueCriterionTest$MyIndividual0%   (0/1)0%   (0/1)0%   (0/11)0%   (0/3)
MinimalQualityCriteriaValueCriterionTest$MyIndividual (MinimalQualityCriteria... 0%   (0/1)0%   (0/11)0%   (0/3)

1package de.uka.ipd.sdq.tcfmoop.tests;
2 
3import static org.junit.Assert.*;
4 
5import java.util.HashMap;
6import java.util.HashSet;
7import java.util.Map;
8 
9import org.junit.Before;
10import org.junit.Test;
11import org.opt4j.common.archive.DefaultArchive;
12import org.opt4j.core.Archive;
13import org.opt4j.core.DoubleValue;
14import org.opt4j.core.Individual;
15import org.opt4j.core.IndividualStateListener;
16import org.opt4j.core.Objective;
17import org.opt4j.core.Objectives;
18import org.opt4j.core.Population;
19import org.opt4j.core.Value;
20import org.opt4j.core.Objective.Sign;
21import org.opt4j.core.domination.ParetoDomination;
22 
23import de.uka.ipd.sdq.tcfmoop.config.MinimalQualityCriteriaValueConfig;
24import de.uka.ipd.sdq.tcfmoop.terminationcriteria.MinimalQualityCriteriaValueCriterion;
25 
26/**
27 * @author Atanas Dimitrov
28 *
29 */
30public class MinimalQualityCriteriaValueCriterionTest {
31        MinimalQualityCriteriaValueConfig mqcvconf;
32        MinimalQualityCriteriaValueCriterion mqcvcrit;
33        
34        Archive archive = new DefaultArchive();
35 
36        Objectives o1 = new Objectives(new ParetoDomination());
37        Objectives o2 = new Objectives(new ParetoDomination());
38        Objectives o3 = new Objectives(new ParetoDomination());
39        Objectives o4 = new Objectives(new ParetoDomination());
40        Objectives o5 = new Objectives(new ParetoDomination());
41        
42        MyIndividual i1 = new MyIndividual();
43        MyIndividual i2 = new MyIndividual();
44        MyIndividual i3 = new MyIndividual();
45        MyIndividual i4 = new MyIndividual();
46        MyIndividual i5 = new MyIndividual(); //signifficant
47        
48        Objective X = new Objective("X", Sign.MIN);
49        Objective Y = new Objective("Y", Sign.MIN);
50        
51        /**
52         * @throws java.lang.Exception
53         */
54        @Before
55        public void setUp() throws Exception {
56                
57                mqcvconf = new MinimalQualityCriteriaValueConfig();
58                
59                o1.add(X, 2);
60                o1.add(Y, 6);
61                
62                o2.add(X, 4);
63                o2.add(Y, 3);
64                                
65                o3.add(X, 3);
66                o3.add(Y, 1.5);
67                
68                o4.add(X, 4);
69                o4.add(Y, 0.5);
70                
71                i1.setObjectives(o1);
72                i2.setObjectives(o2);
73                i3.setObjectives(o3);
74                i4.setObjectives(o4);
75                
76                archive.add(i1);
77                archive.add(i2);
78                archive.add(i3);
79                archive.add(i4);
80                
81                o5.add(X, 2);
82                o5.add(Y, 0.6);
83                i5.setObjectives(o5);
84                
85                mqcvconf.setNumberOfCandidatesToConform(3);
86                
87                Map<Objective, Value<?>> configuredObjects = new HashMap<Objective, Value<?>>();
88                
89                configuredObjects.put(X, new DoubleValue(5d));
90                configuredObjects.put(Y, new DoubleValue(2.5));
91                
92                mqcvconf.setObjectiveMinimalValues(configuredObjects);
93                
94                if(!mqcvconf.validateConfiguration()){
95                        throw new Exception();
96                }
97                
98        }
99 
100        /**
101         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
102         */
103        @Test
104        public void testNotEnoughConformingCandidates() {
105                Population population = new Population();
106                population.add(i1);
107                
108                //Not Enough candidates
109                mqcvcrit = new MinimalQualityCriteriaValueCriterion(mqcvconf, population, archive);
110                mqcvcrit.evaluate(0, 0);
111                assertFalse(mqcvcrit.getEvaluationResult());
112                
113        }
114        
115        /**
116         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
117         */
118        @Test
119        public void testEnoughConformingCandidates() {
120                Population population = new Population();
121                population.add(i1);
122                
123                mqcvcrit = new MinimalQualityCriteriaValueCriterion(mqcvconf, population, archive);
124                
125                archive.remove(i2);
126                archive.add(i5);
127                
128                //Enough conforming candidates
129                mqcvcrit.evaluate(0, 0);
130                assertTrue(mqcvcrit.getEvaluationResult());
131                
132        }
133        
134        public class MyIndividual extends Individual{
135                public MyIndividual(){
136                        this.setIndividualStatusListeners(new HashSet<IndividualStateListener>());
137                }
138        }
139        
140}

[all classes][de.uka.ipd.sdq.tcfmoop.tests]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov