diff options
author | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-08-29 17:21:52 +0100 |
---|---|---|
committer | Dinh Danh Le <dinh.danh.le@ericsson.com> | 2018-09-05 12:48:49 +0100 |
commit | 825ae627d4378c5cc7ab4b7d5f4b4ffefcb7977e (patch) | |
tree | ad4ca360252379ed8e07bc5c599cd4aa6e240199 /examples/examples-adaptive/src/test | |
parent | f7689b84472ab4698d9d96f1de08402208d99ca8 (diff) |
Fix checkstyle warnings in examples
Change-Id: Iad533f3987792d8713426234f3277c1ef6b72284
Issue-ID: POLICY-1034
Signed-off-by: Dinh Danh Le <dinh.danh.le@ericsson.com>
Diffstat (limited to 'examples/examples-adaptive/src/test')
8 files changed, 46 insertions, 29 deletions
diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionDBWrite.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionDbWrite.java index 9affa7876..8f54bf12f 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionDBWrite.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionDbWrite.java @@ -31,10 +31,14 @@ import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -public class TestAnomalyDetectionDBWrite { +public class TestAnomalyDetectionDbWrite { private Connection connection; TestApexModel<AxPolicyModel> testApexModel; + /** + * Sets up embedded Derby database and the Apex anomaly detection model for the tests. + * @throws Exception exception to be thrown while setting up the database connection + */ @Before public void setup() throws Exception { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); @@ -50,11 +54,10 @@ public class TestAnomalyDetectionDBWrite { } @Test - public void testModelWriteReadJPA() throws Exception { + public void testModelWriteReadJpa() throws Exception { final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); - testApexModel.testApexModelWriteReadJpa(DaoParameters); } } diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModel.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModel.java index 3782f2d88..9e631ef2e 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModel.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModel.java @@ -38,6 +38,10 @@ public class TestAnomalyDetectionModel { private Connection connection; TestApexModel<AxPolicyModel> testApexModel; + /** + * Sets up embedded Derby database and the Apex anomaly detection model for the tests. + * @throws Exception exception to be thrown while setting up the database connection + */ @Before public void setup() throws Exception { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); @@ -59,17 +63,17 @@ public class TestAnomalyDetectionModel { } @Test - public void testModelWriteReadXML() throws Exception { + public void testModelWriteReadXml() throws Exception { testApexModel.testApexModelWriteReadXml(); } @Test - public void testModelWriteReadJSON() throws Exception { + public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } @Test - public void testModelWriteReadJPA() throws Exception { + public void testModelWriteReadJpa() throws Exception { final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModelCreator.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModelCreator.java index 2b50d69ab..439452cec 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModelCreator.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionModelCreator.java @@ -25,6 +25,7 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; /** + * The class TestAnomalyDetectionModelCreator. * @author Liam Fallon (liam.fallon@ericsson.com) */ public class TestAnomalyDetectionModelCreator implements TestApexModelCreator<AxPolicyModel> { diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java index 3d3fad973..1925a53f5 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTSLUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAnomalyDetectionTslUseCase.java @@ -56,8 +56,8 @@ import org.slf4j.ext.XLoggerFactory; * * @author John Keeney (John.Keeney@ericsson.com) */ -public class TestAnomalyDetectionTSLUseCase { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestAnomalyDetectionTSLUseCase.class); +public class TestAnomalyDetectionTslUseCase { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestAnomalyDetectionTslUseCase.class); private static final int MAXITERATIONS = 3660; private static final Random RAND = new Random(System.currentTimeMillis()); @@ -107,7 +107,7 @@ public class TestAnomalyDetectionTSLUseCase { @Test // once through the long running test below - public void TestAnomalyDetectionTSL() throws ApexException, InterruptedException, IOException { + public void testAnomalyDetectionTsl() throws ApexException, InterruptedException, IOException { final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel(); assertNotNull(apexPolicyModel); @@ -156,10 +156,10 @@ public class TestAnomalyDetectionTSLUseCase { // Test is disabled by default. uncomment below, or execute using the main() method // @Test // EG Dos command: apex-core.engine> mvn - // -Dtest=org.onap.policy.apex.core.engine.ml.TestAnomalyDetectionTSLUseCase test | findstr /L /C:"Apex [main] DEBUG + // -Dtest=org.onap.policy.apex.core.engine.ml.TestAnomalyDetectionTslUseCase test | findstr /L /C:"Apex [main] DEBUG // c.e.a.e.TaskSelectionExecutionLogging - // TestAnomalyDetectionTSL_Policy0000DecideStateTaskSelectionLogic.getTask():" - public void TestAnomalyDetectionTSL_main() throws ApexException, InterruptedException, IOException { + public void testAnomalyDetectionTslmain() throws ApexException, InterruptedException, IOException { final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAnomalyDetectionPolicyModel(); assertNotNull(apexPolicyModel); @@ -206,6 +206,6 @@ public class TestAnomalyDetectionTSLUseCase { } public static void main(final String[] args) throws ApexException, InterruptedException, IOException { - new TestAnomalyDetectionTSLUseCase().TestAnomalyDetectionTSL_main(); + new TestAnomalyDetectionTslUseCase().testAnomalyDetectionTslmain(); } } diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnDBWrite.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnDbWrite.java index e096105d9..d4c1ab193 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnDBWrite.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnDbWrite.java @@ -31,10 +31,14 @@ import org.onap.policy.apex.model.basicmodel.dao.DaoParameters; import org.onap.policy.apex.model.basicmodel.test.TestApexModel; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; -public class TestAutoLearnDBWrite { +public class TestAutoLearnDbWrite { private Connection connection; TestApexModel<AxPolicyModel> testApexModel; + /** + * Sets up embedded Derby database and the Apex AutoLearn model for the tests. + * @throws Exception exception to be thrown while setting up the database connection + */ @Before public void setup() throws Exception { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); @@ -50,7 +54,7 @@ public class TestAutoLearnDBWrite { } @Test - public void testModelWriteReadJPA() throws Exception { + public void testModelWriteReadJpa() throws Exception { final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModel.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModel.java index beb7a9c80..9bf7ce57a 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModel.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModel.java @@ -38,6 +38,10 @@ public class TestAutoLearnModel { private Connection connection; TestApexModel<AxPolicyModel> testApexModel; + /** + * Sets up embedded Derby database and the Apex AutoLearn model for the tests. + * @throws Exception exception to be thrown while setting up the database connection + */ @Before public void setup() throws Exception { Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance(); @@ -59,17 +63,17 @@ public class TestAutoLearnModel { } @Test - public void testModelWriteReadXML() throws Exception { + public void testModelWriteReadXml() throws Exception { testApexModel.testApexModelWriteReadXml(); } @Test - public void testModelWriteReadJSON() throws Exception { + public void testModelWriteReadJson() throws Exception { testApexModel.testApexModelWriteReadJson(); } @Test - public void testModelWriteReadJPA() throws Exception { + public void testModelWriteReadJpa() throws Exception { final DaoParameters DaoParameters = new DaoParameters(); DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao"); DaoParameters.setPersistenceUnit("AdaptiveModelsTest"); diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModelCreator.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModelCreator.java index 11f1991bf..35d049dc7 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModelCreator.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnModelCreator.java @@ -25,6 +25,7 @@ import org.onap.policy.apex.model.basicmodel.test.TestApexModelCreator; import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel; /** + * The class TestAutoLearnModelCreator. * @author Liam Fallon (liam.fallon@ericsson.com) */ public class TestAutoLearnModelCreator implements TestApexModelCreator<AxPolicyModel> { diff --git a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java index 723b56653..ce9a07e16 100644 --- a/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTSLUseCase.java +++ b/examples/examples-adaptive/src/test/java/org/onap/policy/apex/examples/adaptive/TestAutoLearnTslUseCase.java @@ -54,8 +54,8 @@ import org.slf4j.ext.XLoggerFactory; * * @author John Keeney (John.Keeney@ericsson.com) */ -public class TestAutoLearnTSLUseCase { - private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestAutoLearnTSLUseCase.class); +public class TestAutoLearnTslUseCase { + private static final XLogger LOGGER = XLoggerFactory.getXLogger(TestAutoLearnTslUseCase.class); private static final int MAXITERATIONS = 1000; private static final Random rand = new Random(System.currentTimeMillis()); @@ -105,7 +105,7 @@ public class TestAutoLearnTSLUseCase { @Test // once through the long running test below - public void TestAutoLearnTSL() throws ApexException, InterruptedException, IOException { + public void testAutoLearnTsl() throws ApexException, InterruptedException, IOException { final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel(); assertNotNull(apexPolicyModel); @@ -153,9 +153,9 @@ public class TestAutoLearnTSLUseCase { * @throws IOException Signals that an I/O exception has occurred. */ // @Test - public void TestAutoLearnTSL_main() throws ApexException, InterruptedException, IOException { + public void testAutoLearnTslMain() throws ApexException, InterruptedException, IOException { - final double WANT = 50.0; + final double dwant = 50.0; final double toleranceTileJump = 3.0; final AxPolicyModel apexPolicyModel = new AdaptiveDomainModelFactory().getAutoLearnPolicyModel(); @@ -179,10 +179,10 @@ public class TestAutoLearnTSLUseCase { final EnEvent triggerEvent = apexEngine1.createEvent(new AxArtifactKey("AutoLearnTriggerEvent", "0.0.1")); assertNotNull(triggerEvent); - final double MIN = -100; - final double MAX = 100; + final double dmin = -100; + final double dmax = 100; - double rval = (((rand.nextGaussian() + 1) / 2) * (MAX - MIN)) + MIN; + double rval = (((rand.nextGaussian() + 1) / 2) * (dmax - dmin)) + dmin; triggerEvent.put("MonitoredValue", rval); triggerEvent.put("LastMonitoredValue", 0); @@ -207,13 +207,13 @@ public class TestAutoLearnTSLUseCase { avcount = Math.min((avcount + 1), 20); // maintain average of only the last 20 values avval = ((avval * (avcount - 1)) + val) / (avcount); - distance = Math.abs(WANT - avval); + distance = Math.abs(dwant - avval); if (distance < toleranceTileJump) { - rval = (((rand.nextGaussian() + 1) / 2) * (MAX - MIN)) + MIN; + rval = (((rand.nextGaussian() + 1) / 2) * (dmax - dmin)) + dmin; val = rval; triggerEvent.put("MonitoredValue", val); LOGGER.info("Iteration " + iteration + ": Average " + avval + " has become closer (" + distance - + ") than " + toleranceTileJump + " to " + WANT + " so reseting val:\t\t\t\t\t\t\t\t" + val); + + ") than " + toleranceTileJump + " to " + dwant + " so reseting val:\t\t\t\t\t\t\t\t" + val); avval = 0; avcount = 0; } @@ -229,6 +229,6 @@ public class TestAutoLearnTSLUseCase { } public static void main(final String[] args) throws ApexException, InterruptedException, IOException { - new TestAutoLearnTSLUseCase().TestAutoLearnTSL_main(); + new TestAutoLearnTslUseCase().testAutoLearnTslMain(); } } |