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 [GivenParetoFrontIsReachedCriterionTest.java]

nameclass, %method, %block, %line, %
GivenParetoFrontIsReachedCriterionTest.java0%   (0/2)0%   (0/6)0%   (0/358)0%   (0/72)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GivenParetoFrontIsReachedCriterionTest0%   (0/1)0%   (0/5)0%   (0/347)0%   (0/69)
GivenParetoFrontIsReachedCriterionTest (): void 0%   (0/1)0%   (0/55)0%   (0/9)
setUp (): void 0%   (0/1)0%   (0/175)0%   (0/36)
test100PercentCoverage (): void 0%   (0/1)0%   (0/42)0%   (0/9)
test25PercentCoverage (): void 0%   (0/1)0%   (0/33)0%   (0/6)
test55PercentCoverage (): void 0%   (0/1)0%   (0/42)0%   (0/9)
     
class GivenParetoFrontIsReachedCriterionTest$MyIndividual0%   (0/1)0%   (0/1)0%   (0/11)0%   (0/3)
GivenParetoFrontIsReachedCriterionTest$MyIndividual (GivenParetoFrontIsReache... 0%   (0/1)0%   (0/11)0%   (0/3)

1/**
2 * 
3 */
4package de.uka.ipd.sdq.tcfmoop.tests;
5 
6import static org.junit.Assert.*;
7 
8import java.util.HashSet;
9import java.util.LinkedList;
10import java.util.List;
11 
12import org.junit.Before;
13import org.junit.Test;
14import org.opt4j.common.archive.DefaultArchive;
15import org.opt4j.core.Archive;
16import org.opt4j.core.Individual;
17import org.opt4j.core.IndividualStateListener;
18import org.opt4j.core.Objective;
19import org.opt4j.core.Objectives;
20import org.opt4j.core.Objective.Sign;
21import org.opt4j.core.domination.ParetoDomination;
22 
23import de.uka.ipd.sdq.tcfmoop.config.GivenParetoFrontIsReachedConfig;
24import de.uka.ipd.sdq.tcfmoop.config.exceptions.InvalidConfigException;
25import de.uka.ipd.sdq.tcfmoop.terminationcriteria.GivenParetoFrontIsReachedCriterion;
26 
27/**
28 * @author Atanas Dimitrov
29 *
30 */
31public class GivenParetoFrontIsReachedCriterionTest {
32        GivenParetoFrontIsReachedConfig gpfirconf;
33        GivenParetoFrontIsReachedCriterion gpfircrit;
34        Archive front25 = new DefaultArchive();
35        Archive front75 = new DefaultArchive();
36        Archive front100 = new DefaultArchive();
37        List<Objectives> paretoFront = new LinkedList<Objectives>();
38        Objectives o1 = new Objectives(new ParetoDomination());
39        Objectives o2 = new Objectives(new ParetoDomination());
40        Objectives o3 = new Objectives(new ParetoDomination());
41        Objectives o4 = new Objectives(new ParetoDomination());
42        
43        /**
44         * @throws java.lang.Exception
45         */
46        @Before
47        public void setUp() throws Exception {
48                
49                Objective X = new Objective("X", Sign.MIN);
50                Objective Y = new Objective("Y", Sign.MAX);
51                
52                gpfirconf = new GivenParetoFrontIsReachedConfig();
53                
54                o1.add(X, 5);
55                o1.add(Y, 5);
56                
57                o2.add(X, 4);
58                o2.add(Y, 4);
59                                
60                o3.add(X, 3);
61                o3.add(Y, 3);
62                
63                o4.add(X, 2);
64                o4.add(Y, 2);
65                
66                paretoFront.add(o1);
67                paretoFront.add(o2);
68                paretoFront.add(o3);
69                paretoFront.add(o4);
70                
71                gpfirconf.setParetoFront(paretoFront);
72                gpfirconf.setPercentagesToCover(0.75);
73                if(!gpfirconf.validateConfiguration()){
74                        throw new Exception();
75                }
76                
77                MyIndividual i1 = new MyIndividual();
78                i1.setObjectives(o1);
79                MyIndividual i2 = new MyIndividual();
80                i2.setObjectives(o2);
81                MyIndividual i3 = new MyIndividual();
82                i3.setObjectives(o3);
83                MyIndividual i4 = new MyIndividual();
84                i4.setObjectives(o4);
85                
86                front25.add(i1);
87                
88                front75.add(i1);
89                front75.add(i2);
90                front75.add(i3);
91                
92                front100.add(i1);
93                front100.add(i2);
94                front100.add(i3);
95                front100.add(i4);
96                
97        }
98 
99        @Test
100        public void test25PercentCoverage() {
101                
102                int initialParetoFrontSize = this.paretoFront.size();
103                
104                gpfircrit = new GivenParetoFrontIsReachedCriterion(gpfirconf, null, front25);
105                gpfircrit.evaluate(0, 0);
106                assertFalse(gpfircrit.getEvaluationResult());
107                
108                assertTrue(this.paretoFront.size() == initialParetoFrontSize);
109                
110        }
111        
112        @Test
113        public void test55PercentCoverage() {
114                
115                int initialParetoFrontSize = this.paretoFront.size();
116                
117                try {
118                        gpfirconf.setParetoFront(paretoFront);
119                } catch (InvalidConfigException e) {
120                        // TODO Auto-generated catch block
121                        e.printStackTrace();
122                }
123                gpfircrit = new GivenParetoFrontIsReachedCriterion(gpfirconf, null, front75);
124                gpfircrit.evaluate(0, 0);
125                assertTrue(gpfircrit.getEvaluationResult());
126                
127                assertTrue(this.paretoFront.size() == initialParetoFrontSize);
128                
129        }
130        
131        @Test
132        public void test100PercentCoverage() {
133                
134                int initialParetoFrontSize = this.paretoFront.size();
135                                
136                try {
137                        gpfirconf.setParetoFront(paretoFront);
138                } catch (InvalidConfigException e) {
139                        // TODO Auto-generated catch block
140                        e.printStackTrace();
141                }
142                gpfircrit = new GivenParetoFrontIsReachedCriterion(gpfirconf, null, front100);
143                gpfircrit.evaluate(0, 0);
144                assertTrue(gpfircrit.getEvaluationResult());
145                
146                assertTrue(this.paretoFront.size() == initialParetoFrontSize);
147                
148        }
149        
150        
151        
152        public class MyIndividual extends Individual{
153                public MyIndividual(){
154                        this.setIndividualStatusListeners(new HashSet<IndividualStateListener>());
155                }
156        }
157 
158}

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