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

COVERAGE SUMMARY FOR SOURCE FILE [TestUtils.java]

nameclass, %method, %block, %line, %
TestUtils.java0%   (0/1)0%   (0/5)0%   (0/175)0%   (0/36)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestUtils0%   (0/1)0%   (0/5)0%   (0/175)0%   (0/36)
TestUtils (): void 0%   (0/1)0%   (0/3)0%   (0/1)
createSampleSequence (int, int): List 0%   (0/1)0%   (0/45)0%   (0/7)
loadMeasurements (IDAOFactory, String, int, int): Collection 0%   (0/1)0%   (0/35)0%   (0/7)
loadMeasurements (IDAOFactory, int, int, int): Collection 0%   (0/1)0%   (0/35)0%   (0/8)
loadMeasurementsFromExperiment (Experiment, int, int): Collection 0%   (0/1)0%   (0/57)0%   (0/13)

1package de.uka.ipd.sdq.statistics.test;
2 
3import java.util.ArrayList;
4import java.util.Collection;
5import java.util.Iterator;
6import java.util.List;
7import java.util.Random;
8 
9import de.uka.ipd.sdq.sensorframework.entities.Experiment;
10import de.uka.ipd.sdq.sensorframework.entities.ExperimentRun;
11import de.uka.ipd.sdq.sensorframework.entities.Measurement;
12import de.uka.ipd.sdq.sensorframework.entities.Sensor;
13import de.uka.ipd.sdq.sensorframework.entities.SensorAndMeasurements;
14import de.uka.ipd.sdq.sensorframework.entities.TimeSpanSensor;
15import de.uka.ipd.sdq.sensorframework.entities.dao.IDAOFactory;
16import de.uka.ipd.sdq.sensorframework.entities.dao.IExperimentDAO;
17 
18public class TestUtils {
19 
20        /**
21         * 
22         * @param numberOfSamples
23         * @param desiredLag
24         *            set lag > 1 in order to obtain a sequence of dependent values.
25         * @return
26         */
27        public static List<Double> createSampleSequence(int numberOfSamples,
28                        int desiredLag) {
29                Random random = new Random();
30                List<Double> samples = new ArrayList<Double>();
31                for (int i = 0; i < numberOfSamples; i += desiredLag) {
32                        double randDbl = random.nextDouble();
33                        for (int j = 0; j < desiredLag && i + j < numberOfSamples; j++) {
34                                samples.add(randDbl + (j * randDbl));
35                        }
36                }
37 
38                return samples;
39        }
40        
41        public static Collection<Measurement> loadMeasurements(IDAOFactory factory,
42                        String experimentName, int runId, int sensorId) {
43                
44                IExperimentDAO experimentDAO = factory.createExperimentDAO();
45                
46                Collection<Experiment> experiment = experimentDAO.findByExperimentName(experimentName);
47                Iterator iterator = experiment.iterator();
48                if (iterator.hasNext()) {
49                        Experiment experiment2 = (Experiment) iterator.next();
50                        return loadMeasurementsFromExperiment(experiment2, runId, sensorId);
51                } else {
52                        throw new RuntimeException("No Experiment with name "+experimentName+" available.");
53                }
54                
55                
56                
57        }
58 
59        private static Collection<Measurement> loadMeasurementsFromExperiment(
60                        Experiment experiment, int runId, int sensorId) {
61                // Obtain (time span) sensor with specified id
62                TimeSpanSensor sensor = null;
63                for (Sensor s : experiment.getSensors()) {
64                        if (s.getSensorID() == sensorId) {
65                                 if (s instanceof TimeSpanSensor) {
66                                         sensor = (TimeSpanSensor)s;
67                                         break;
68                                 }
69                        }
70                }
71                
72                // Obtain experiment run with specified id
73                ExperimentRun run = null;
74                for (ExperimentRun r : experiment.getExperimentRuns()) {
75                        if (r.getExperimentRunID() == runId) {
76                                run = r;
77                                break;
78                        }
79                }
80                
81                SensorAndMeasurements sam = run.getMeasurementsOfSensor(sensor);
82                return sam.getMeasurements();
83        }
84 
85        public static Collection<Measurement> loadMeasurements(IDAOFactory factory,
86                        int experimentId, int runId, int sensorId) {
87                IExperimentDAO experimentDAO = factory.createExperimentDAO();
88                
89                // Obtain experiment with specified id
90                Experiment experiment = null;
91                for (Experiment e : experimentDAO.getExperiments()) {
92                        System.out.println(e.getExperimentName());
93                        if (e.getExperimentID() == experimentId) {
94                                experiment = e;
95                                break;
96                        }
97                }
98                return loadMeasurementsFromExperiment(experiment, runId, sensorId);
99        
100 
101        }
102 
103}

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