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

nameclass, %method, %block, %line, %
NoNewParetoOptimalCandidatesCriterionTest.java0%   (0/2)0%   (0/6)0%   (0/389)0%   (0/75)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class NoNewParetoOptimalCandidatesCriterionTest0%   (0/1)0%   (0/5)0%   (0/378)0%   (0/72)
NoNewParetoOptimalCandidatesCriterionTest (): void 0%   (0/1)0%   (0/92)0%   (0/14)
setUp (): void 0%   (0/1)0%   (0/127)0%   (0/24)
testEmptyArchive (): void 0%   (0/1)0%   (0/41)0%   (0/9)
testNoNewCandidates (): void 0%   (0/1)0%   (0/47)0%   (0/10)
testOneNewCandidate (): void 0%   (0/1)0%   (0/71)0%   (0/15)
     
class NoNewParetoOptimalCandidatesCriterionTest$MyIndividual0%   (0/1)0%   (0/1)0%   (0/11)0%   (0/3)
NoNewParetoOptimalCandidatesCriterionTest$MyIndividual (NoNewParetoOptimalCan... 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;
9 
10import org.junit.Before;
11import org.junit.Test;
12import org.opt4j.common.archive.DefaultArchive;
13import org.opt4j.core.Archive;
14import org.opt4j.core.Individual;
15import org.opt4j.core.IndividualStateListener;
16import org.opt4j.core.Objective;
17import org.opt4j.core.Objectives;
18import org.opt4j.core.Objective.Sign;
19import org.opt4j.core.domination.ParetoDomination;
20 
21import de.uka.ipd.sdq.tcfmoop.config.NoNewParetoOptimalCandidatesFoundConfig;
22import de.uka.ipd.sdq.tcfmoop.terminationcriteria.NoNewParetoOptimalCandidatesFoundCriterion;
23 
24/**
25 * @author Atanas Dimitrov
26 *
27 */
28public class NoNewParetoOptimalCandidatesCriterionTest {
29        NoNewParetoOptimalCandidatesFoundConfig nnpocconf;
30        NoNewParetoOptimalCandidatesFoundCriterion nnpoccrit;
31        
32        Archive archive = new DefaultArchive();
33 
34        Objectives o1 = new Objectives(new ParetoDomination());
35        Objectives o2 = new Objectives(new ParetoDomination());
36        Objectives o3 = new Objectives(new ParetoDomination());
37        Objectives o4 = new Objectives(new ParetoDomination());
38        Objectives o5 = new Objectives(new ParetoDomination());
39        
40        MyIndividual i1 = new MyIndividual();
41        MyIndividual i2 = new MyIndividual();
42        MyIndividual i3 = new MyIndividual();
43        MyIndividual i4 = new MyIndividual();
44        MyIndividual i5 = new MyIndividual();
45        
46        Objective X = new Objective("X", Sign.MIN);
47        Objective Y = new Objective("Y", Sign.MIN);
48        
49        /**
50         * @throws java.lang.Exception
51         */
52        @Before
53        public void setUp() throws Exception {
54                
55                nnpocconf = new NoNewParetoOptimalCandidatesFoundConfig();
56                
57                o1.add(X, 2);
58                o1.add(Y, 6);
59                
60                o2.add(X, 4);
61                o2.add(Y, 3);
62                                
63                o3.add(X, 6);
64                o3.add(Y, 1);
65                
66                o4.add(X, 8);
67                o4.add(Y, 0.5);
68                
69                o5.add(X, 9);
70                o5.add(Y, 1.5);
71                
72                i1.setObjectives(o1);
73                i2.setObjectives(o2);
74                i3.setObjectives(o3);
75                i4.setObjectives(o4);
76                i5.setObjectives(o5);
77                
78                archive.add(i1);
79                archive.add(i2);
80                archive.add(i3);
81                archive.add(i4);                
82                
83                nnpocconf.setIterationsWithoutNewCandidates(3);
84                if(!nnpocconf.validateConfiguration()){
85                        throw new Exception();
86                }
87                
88        }
89 
90        /**
91         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
92         */
93        @Test
94        public void testNoNewCandidates() {
95                
96                nnpoccrit = new NoNewParetoOptimalCandidatesFoundCriterion(nnpocconf, null, archive);
97                
98                nnpoccrit.evaluate(0, 0);
99                assertFalse(nnpoccrit.getEvaluationResult());
100                nnpoccrit.evaluate(0, 0);
101                assertFalse(nnpoccrit.getEvaluationResult());
102                nnpoccrit.evaluate(0, 0);
103                assertFalse(nnpoccrit.getEvaluationResult());
104                nnpoccrit.evaluate(0, 0);
105                assertTrue(nnpoccrit.getEvaluationResult());
106                
107        }
108        
109        /**
110         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
111         */
112        @Test
113        public void testOneNewCandidate() {
114                
115                nnpoccrit = new NoNewParetoOptimalCandidatesFoundCriterion(nnpocconf, null, archive);
116                
117                nnpoccrit.evaluate(0, 0);
118                assertFalse(nnpoccrit.getEvaluationResult());
119                nnpoccrit.evaluate(0, 0);
120                assertFalse(nnpoccrit.getEvaluationResult());
121                archive.add(i5);
122                nnpoccrit.evaluate(0, 0);
123                assertFalse(nnpoccrit.getEvaluationResult());
124                nnpoccrit.evaluate(0, 0);
125                assertFalse(nnpoccrit.getEvaluationResult());
126                nnpoccrit.evaluate(0, 0);
127                assertFalse(nnpoccrit.getEvaluationResult());
128                nnpoccrit.evaluate(0, 0);
129                assertTrue(nnpoccrit.getEvaluationResult());
130                
131        }
132        
133        /**
134         * Test method for {@link de.uka.ipd.sdq.tcfmoop.terminationcriteria.AbstractTerminationCriterion#getEvaluationResult()}.
135         */
136        @Test
137        public void testEmptyArchive() {
138                
139                nnpoccrit = new NoNewParetoOptimalCandidatesFoundCriterion(nnpocconf, null, archive);
140                archive.clear();
141                nnpoccrit.evaluate(0, 0);
142                assertFalse(nnpoccrit.getEvaluationResult());
143                nnpoccrit.evaluate(0, 0);
144                assertFalse(nnpoccrit.getEvaluationResult());
145                nnpoccrit.evaluate(0, 0);
146                assertTrue(nnpoccrit.getEvaluationResult());
147                
148        }
149        
150        public class MyIndividual extends Individual{
151                public MyIndividual(){
152                        this.setIndividualStatusListeners(new HashSet<IndividualStateListener>());
153                }
154        }
155 
156}

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