diff --git a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightCalculatorTest.java b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightsWeightingFunctionTest.java similarity index 59% rename from edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightCalculatorTest.java rename to edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightsWeightingFunctionTest.java index a623a2c852d9a983ca1b5f903d4b74b624e72aa5..55666bc74bedd899f21b50ca77b917740b153914 100644 --- a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightCalculatorTest.java +++ b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/RandomWeightsWeightingFunctionTest.java @@ -1,21 +1,18 @@ package edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotSame; import java.util.Random; import org.junit.Before; import org.junit.Test; -import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.IWeightingFunctionCalculator; -import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.RandomWeightCalculator; import edu.kit.ipd.descartes.mm.adaptation.AdaptationFactory; import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; -public class RandomWeightCalculatorTest { +public class RandomWeightsWeightingFunctionTest { - IWeightingFunctionCalculator randomCalculator = new RandomWeightCalculator(); + IWeightingFunction randomCalculator = new RandomWeightsWeightingFunction(); WeightedTactic wt = null; @Before @@ -33,13 +30,4 @@ public class RandomWeightCalculatorTest { assertEquals(r.nextDouble(), randomCalculator.calculateWeight(wt),1.0); assertEquals(0.0, wt.getDefaultWeight(), 0.0); } - - @Test - public void testCalculateAndSetWeight() { - randomCalculator.updateWeight(wt); - - assertNotSame(1.0, wt.getCurrentWeight()); - assertEquals(0.0, wt.getDefaultWeight(), 0.0); - } - } diff --git a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumCalculatorTest.java b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumWeightingFunctionTest.java similarity index 91% rename from edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumCalculatorTest.java rename to edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumWeightingFunctionTest.java index 8e1cb880719a62e4a7f7312bf399db205756396c..f1ba253a582574c0d1ea5c2db0d008fe171b6d6d 100644 --- a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumCalculatorTest.java +++ b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightedSumWeightingFunctionTest.java @@ -13,8 +13,8 @@ import org.junit.Test; import edu.kit.ipd.descartes.adaptation.AbstractTest; import edu.kit.ipd.descartes.adaptation.AdaptationControl; -import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.IWeightingFunctionCalculator; -import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.WeightedSumCalculator; +import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.IWeightingFunction; +import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.WeightedSum; import edu.kit.ipd.descartes.adaptation.model.perfdatarepo.PerformanceDataRepositoryModelLoader; import edu.kit.ipd.descartes.mm.adaptation.AdaptationFactory; import edu.kit.ipd.descartes.mm.adaptation.WeightedMetric; @@ -27,12 +27,12 @@ import edu.kit.ipd.descartes.perfdatarepo.PerfdatarepoFactory; import edu.kit.ipd.descartes.perfdatarepo.PerformanceDataRepository; import edu.kit.ipd.descartes.perfdatarepo.Result; -public class WeightedSumCalculatorTest extends AbstractTest { +public class WeightedSumWeightingFunctionTest extends AbstractTest { private static final String PROP_TEST_PERF_DATA_REPO_XMI_FILE_PATH_NAME = "perfdatarepo.test"; private static final double NEW_WEIGHT = 99.8; - IWeightingFunctionCalculator weightedSum; + IWeightingFunction weightedSum; WeightedTactic wt = null; WeightingFunction fun = null; AdaptationControl control = null; @@ -67,7 +67,7 @@ public class WeightedSumCalculatorTest extends AbstractTest { fun.getWeightedMetrics().add(wmRespTime); fun.getWeightedMetrics().add(wmUtil); - weightedSum = new WeightedSumCalculator(fun); + weightedSum = new WeightedSum(fun); wt = AdaptationFactory.eINSTANCE.createWeightedTactic(); @@ -114,13 +114,6 @@ public class WeightedSumCalculatorTest extends AbstractTest { assertEquals(wt.getDefaultWeight(), 0.0, 0); } - @Test - public void testCalculateAndSetWeight() { - weightedSum.updateWeight(wt); - assertEquals(NEW_WEIGHT, wt.getCurrentWeight(), 0.0); - assertEquals(wt.getDefaultWeight(), 0.0, 0); - } - @Test public void testImpact() { Impact impact = loadImpactFromModel(); @@ -130,7 +123,7 @@ public class WeightedSumCalculatorTest extends AbstractTest { WeightedTactic wt = AdaptationFactory.eINSTANCE.createWeightedTactic(); wt.setLastImpact(impact); - WeightedSumCalculator wSumCalc = new WeightedSumCalculator(testFunction); + WeightedSum wSumCalc = new WeightedSum(testFunction); for (MetricType metricType : metricTypes) { WeightedMetric wm = AdaptationFactory.eINSTANCE.createWeightedMetric(); wm.setMetricType(metricType); diff --git a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightingFunctionHelperTest.java b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightingFunctionHelperTest.java index 25cbf237610035ec68e5fbf2b44fa2282d219078..ae5434a4d0303c6433937a39881e84b2360f5e7f 100644 --- a/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightingFunctionHelperTest.java +++ b/edu.kit.ipd.descartes.adaptation.test/src/edu/kit/ipd/descartes/adaptation/evaluation/weightingfunction/WeightingFunctionHelperTest.java @@ -12,7 +12,7 @@ import org.eclipse.emf.common.util.URI; import org.junit.Before; import org.junit.Test; -import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.WeightingFunctionHelper; +import edu.kit.ipd.descartes.adaptation.evaluation.weightingfunction.WeightedSumWeightingFunctionHelper; import edu.kit.ipd.descartes.adaptation.model.perfdatarepo.PerfDataRepoConverter; import edu.kit.ipd.descartes.adaptation.model.perfdatarepo.PerformanceDataRepositoryModelLoader; import edu.kit.ipd.descartes.mm.adaptation.AdaptationFactory; @@ -73,11 +73,11 @@ public class WeightingFunctionHelperTest { public void testGetWeightForMetricType() { double weight = 0.0; MetricType metricType = getTypeHelper(METRIC_TYPES.RESPONSE_TIME); - weight = WeightingFunctionHelper.getWeightForMetricType(function, metricType); + weight = WeightedSumWeightingFunctionHelper.getWeightForMetricType(function, metricType); assertEquals(Double.NaN, weight, 0.0); metricType = getTypeHelper(METRIC_TYPES.UTILIZATION); - weight = WeightingFunctionHelper.getWeightForMetricType(function, metricType); + weight = WeightedSumWeightingFunctionHelper.getWeightForMetricType(function, metricType); assertEquals(UTIL_WEIGHT, weight, 0.0); } @@ -87,12 +87,12 @@ public class WeightingFunctionHelperTest { MetricType metricType = getTypeHelper(METRIC_TYPES.UTILIZATION); Result emptyResult = PerfdatarepoFactory.eINSTANCE.createResult(); - testValue = WeightingFunctionHelper.getValueForMetricType(metricType, emptyResult); + testValue = WeightedSumWeightingFunctionHelper.getValueForMetricType(metricType, emptyResult); assertEquals(Double.NaN, testValue, 0); Impact impact = perfDataRepo.getImpactHistory().get(0); Result before = impact.getBefore(); - testValue = WeightingFunctionHelper.getValueForMetricType(metricType, before); + testValue = WeightedSumWeightingFunctionHelper.getValueForMetricType(metricType, before); assertEquals(0.4, testValue, 0); } @@ -140,7 +140,7 @@ public class WeightingFunctionHelperTest { MetricValue v2 = i.next(); assertEquals(v1.getMetricType(), v2.getMetricType()); MetricValue v3 = i.next(); - assertTrue(WeightingFunctionHelper.sameMetricType(v2, v3.getMetricType())); + assertTrue(WeightedSumWeightingFunctionHelper.sameMetricType(v2, v3.getMetricType())); } }