Some minor line length and formatting checkstyle warnings fixed.
Change-Id: Ib92069bbdb444560083e6d0dbf5d16a3ab824d82
Issue-ID: POLICY-1074
Signed-off-by: liamfallon <liam.fallon@est.tech>
fail(EXCEPTION_MESSAGE);
} catch (final ContextRuntimeException e) {
assertEquals("Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\":"
- + " LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with"
- + " class \"java.lang.Long\"", e.getMessage());
+ + " LongContextAlbum:0.0.1: object \"zero\" of class \"java.lang.String\" not compatible with"
+ + " class \"java.lang.Long\"", e.getMessage());
LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
}
fail(EXCEPTION_MESSAGE);
} catch (final ContextRuntimeException e) {
assertEquals(
- "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum"
- + ":0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
- e.getMessage());
+ "Failed to set context value for key \"0\" in album \"LongContextAlbum:0.0.1\": LongContextAlbum"
+ + ":0.0.1: object \"\" of class \"java.lang.String\" not compatible with class \"java.lang.Long\"",
+ e.getMessage());
LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
}
fail(EXCEPTION_MESSAGE);
} catch (final ContextRuntimeException e) {
assertEquals("album \"LongContextAlbum:0.0.1\" null values are illegal on key \"0\" for put()",
- e.getMessage());
+ e.getMessage());
LOGGER.trace(NORMAL_TEST_EXCEPTION, e);
}
assertNull(dateContextAlbum.put("date0", tciA));
assertTrue(dateContextAlbum.put("date0", tciA).equals(tciA));
-
assertNull(mapContextAlbum.put("map0", tciC));
assertTrue(mapContextAlbum.put("map0", tciC).equals(tciC));
}
private ContextAlbum getContextAlbum(final String albumKey, final Distributor contextDistributor)
- throws ContextException {
- final ContextAlbum longContextAlbum =
- contextDistributor.createContextAlbum(new AxArtifactKey(albumKey, VERSION));
+ throws ContextException {
+ final ContextAlbum longContextAlbum = contextDistributor
+ .createContextAlbum(new AxArtifactKey(albumKey, VERSION));
assertNotNull(longContextAlbum);
longContextAlbum.setUserArtifactStack(getAxArtifactKeyArray());
return longContextAlbum;
final AxArtifactKey distributorKey = new AxArtifactKey(APEX_DISTRIBUTOR, VERSION);
final Distributor contextDistributor = new DistributorFactory().getDistributor(distributorKey);
-
final AxContextModel multiModel = TestContextAlbumFactory.createMultiAlbumsContextModel();
contextDistributor.registerModel(multiModel);
return contextDistributor;
* The Class {@link BatchDeployer} deploys an Apex model held as an XML or Json file onto an Apex engine. It uses the
* EngDep protocol to communicate with the engine, with the EngDep protocol being carried on Java web sockets.
*
- * <p>
- * This deployer is a simple command line deployer that reads the communication parameters and the location of the Apex
- * model file as arguments.
+ * <p>This deployer is a simple command line deployer that reads the communication parameters and the location of the
+ * Apex model file as arguments.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
* @throws ApexException on Apex errors
*/
public void deployModel(final String modelFileName, final boolean ignoreConflicts, final boolean force)
- throws ApexException {
+ throws ApexException {
engineServiceFacade.deployModel(modelFileName, ignoreConflicts, force);
}
* @throws ApexException on Apex errors
*/
public void deployModel(final AxPolicyModel policyModel, final boolean ignoreConflicts, final boolean force)
- throws ApexException {
+ throws ApexException {
engineServiceFacade.deployModel(policyModel, ignoreConflicts, force);
}
public static void main(final String[] args) throws ApexException {
if (args.length != NUM_ARGUMENTS) {
final String message = "invalid arguments: " + Arrays.toString(args)
- + "\nusage: BatchDeployer <server address> <port address> <model file path";
+ + "\nusage: BatchDeployer <server address> <port address> <model file path";
LOGGER.error(message);
throw new ApexDeploymentException(message);
}
@SuppressWarnings("unchecked")
@Test
public void testDeploymentClientStart() throws Exception {
- DeploymentClient deploymentClient = new DeploymentClient("localhost", 51273);
+ DeploymentClient deploymentClient = new DeploymentClient("localhost", 51332);
final Field factoryField = deploymentClient.getClass().getDeclaredField("factory");
factoryField.setAccessible(true);
Thread clientThread = new Thread(deploymentClient);
clientThread.start();
- ThreadUtilities.sleep(20);
+ ThreadUtilities.sleep(100);
assertTrue(deploymentClient.isStarted());
assertTrue(clientThread.isAlive());
@Test
public void testDeploymentClientStartException() throws Exception {
- DeploymentClient depoymentClient = new DeploymentClient("localhost", 51273);
+ DeploymentClient deploymentClient = new DeploymentClient("localhost", 51273);
- final Field factoryField = depoymentClient.getClass().getDeclaredField("factory");
+ final Field factoryField = deploymentClient.getClass().getDeclaredField("factory");
factoryField.setAccessible(true);
- factoryField.set(depoymentClient, mockServiceFactory);
+ factoryField.set(deploymentClient, mockServiceFactory);
Mockito.doReturn(mockService).when(mockServiceFactory).createClient(anyObject());
Mockito.doNothing().when(mockService).addMessageListener(anyObject());
Mockito.doThrow(new ApexRuntimeException("connection start failed")).when(mockService).startConnection();
- Thread clientThread = new Thread(depoymentClient);
+ Thread clientThread = new Thread(deploymentClient);
clientThread.start();
ThreadUtilities.sleep(50);
- assertFalse(depoymentClient.isStarted());
+ assertFalse(deploymentClient.isStarted());
assertFalse(clientThread.isAlive());
- assertEquals(0, depoymentClient.getReceiveQueue().size());
+ assertEquals(0, deploymentClient.getReceiveQueue().size());
ThreadUtilities.sleep(100);
+
+ deploymentClient.stopClient();
}
}
public boolean getTask(final TaskSelectionExecutionContext executor) {
String idString = executor.subject.getId();
executor.logger.debug(idString);
-
+
String inFieldsString = executor.inFields.toString();
executor.logger.debug(inFieldsString);
-
+
final List<String> tasks = executor.subject.getTaskNames();
size = tasks.size();
autoLearn.setAvDiffs(Arrays.asList(avdiffs));
autoLearn.setCounts(Arrays.asList(counts));
}
-
/**
- * Calculate the return value of the learning
+ * Calculate the return value of the learning.
+ *
* @param diff the difference
- * @param r the random value
+ * @param random the random value
* @param closestupi closest to i upwards
* @param closestdowni closest to i downwards
* @param closestup closest up value
* @param closestdown closest down value
* @return the return value
*/
- private int calculateReturnValue(final double diff, final int r, int closestupi, int closestdowni, double closestup,
- double closestdown) {
+ private int calculateReturnValue(final double diff, final int random, int closestupi, int closestdowni,
+ double closestup, double closestdown) {
if (closestupi == -1 || closestdowni == -1) {
- return r;
+ return random;
}
if (closestupi == closestdowni) {
return closestupi;
import org.junit.Test;
/**
- * Test the JavaExecutorParameters class
+ * Test the JavaExecutorParameters class.
*/
public class JavaExecutorParametersTest {
*
*/
public class JavaStateFinalizerExecutorTest {
+ /**
+ * Initiate Parameters.
+ */
@Before
public void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new EngineParameters());
}
+ /**
+ * Clear down Parameters.
+ */
@After
public void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
try {
parentStateExcutor = new StateExecutor(new ExecutorFactoryImpl());
} catch (StateMachineException e) {
+ fail("test should not throw an exception here");
}
+
AxState state = new AxState();
- parentStateExcutor.setContext(null, state , internalContext);
+ parentStateExcutor.setContext(null, state, internalContext);
AxStateFinalizerLogic stateFinalizerLogic = new AxStateFinalizerLogic();
jsfe.setContext(parentStateExcutor, stateFinalizerLogic, internalContext);
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
- jtseException.getMessage());
+ jtseException.getMessage());
}
AxEvent axEvent = new AxEvent(new AxArtifactKey("Event", "0.0.1"));
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("state finalizer logic failed to run for state finalizer \"NULL:0.0.0:NULL:NULL\"",
- jtseException.getMessage());
+ jtseException.getMessage());
}
stateFinalizerLogic.setLogic("org.onap.policy.apex.plugins.executor.java.DummyJavaStateFinalizerLogic");
fail("test should throw an exception here");
} catch (Exception jtseException) {
assertEquals("execute-post: state finalizer logic execution failure on state \"NULL:0.0.0:NULL:NULL\" "
- + "on finalizer logic NULL:0.0.0:NULL:NULL", jtseException.getMessage());
+ + "on finalizer logic NULL:0.0.0:NULL:NULL", jtseException.getMessage());
}
state.getStateOutputs().put("SelectedOutputIsMe", null);
*
*/
public class JavaTaskExecutorTest {
+ /**
+ * Initiate Parameters.
+ */
@Before
public void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new PersistorParameters());
}
+ /**
+ * Clear Parameters.
+ */
@After
public void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
*
*/
public class JavaTaskSelectExecutorTest {
+ /**
+ * Initiate Parameters.
+ */
@Before
public void initiateParameters() {
ParameterService.register(new DistributorParameters());
ParameterService.register(new PersistorParameters());
}
+ /**
+ * Clear Parameters.
+ */
@After
public void clearParameters() {
ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
EventBatch batch = new EventBatch(1, "TheApexClient");
assertNotNull(batch);
- assertEquals("\"nameSpace\": \"org.onap.policy.apex.sample.events\"", batch.getBatchAsJsonString().substring(4, 53));
+ assertEquals("\"nameSpace\": \"org.onap.policy.apex.sample.events\"",
+ batch.getBatchAsJsonString().substring(4, 53));
EventBatchStats stats = batch.getStats();
assertEquals(1, stats.getBatchSize());
InputEvent ie = batch.getInputEvent(0);
- assertEquals("org.onap.policy.apex.sample.events",ie.getNameSpace());
+ assertEquals("org.onap.policy.apex.sample.events", ie.getNameSpace());
}
}
EventGenerator eventGenerator = new EventGenerator(pars);
- final String[] args =
- { "-rfr", "target", "-c", "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" };
+ final String[] args = { "-rfr", "target", "-c",
+ "target/examples/config/SampleDomain/REST2RESTJsonEventJavascript.json" };
final ApexMain apexMain = new ApexMain(args);
public void testEventGeneratorBadParams() {
System.setOut(new PrintStream(outContent));
- final String[] args =
- { "-zzz" };
+ final String[] args = { "-zzz" };
EventGenerator.main(args);
public void testEventGeneratorHelp() {
System.setOut(new PrintStream(outContent));
- final String[] args = {
- "-h"
- };
+ final String[] args = { "-h" };
EventGenerator.main(args);
public void run() {
EventGenerator.main(null);
}
- }).start();
+ }).start();
ThreadUtilities.sleep(1000);
final String outString = outContent.toString();
@Test
public void testEventGeneratorOutfileGood() {
- EventGeneratorParameters pars =new EventGeneratorParameters();
+ EventGeneratorParameters pars = new EventGeneratorParameters();
pars.setOutFile("target/statsOutFile.json");
EventGenerator generator = new EventGenerator(pars);