diff options
3 files changed, 29 insertions, 29 deletions
diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java index 72987de0a..699ec4584 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/handler/ApexEngineHandler.java @@ -132,7 +132,6 @@ public class ApexEngineHandler { return path.toAbsolutePath().toString(); } catch (final IOException e) { final String errorMessage = "error creating from the properties received in PdpUpdate."; - LOGGER.error(errorMessage, e); throw new ApexStarterException(errorMessage, e); } } diff --git a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java index ed7c00f10..03a8d6e46 100644 --- a/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java +++ b/services/services-onappf/src/main/java/org/onap/policy/apex/services/onappf/parameters/ApexStarterParameterHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,6 @@ public class ApexStarterParameterHandler { } catch (final CoderException e) { final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath() + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage(); - LOGGER.error(errorMessage, e); throw new ApexStarterException(errorMessage, e); } diff --git a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java index e860da7c1..c1c656490 100644 --- a/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java +++ b/testsuites/integration/integration-common/src/main/java/org/onap/policy/apex/testsuites/integration/common/model/java/DefaultTaskLogic.java @@ -1,26 +1,28 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.policy.apex.testsuites.integration.common.model.java; -import java.util.Random; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext; @@ -34,37 +36,37 @@ public class DefaultTaskLogic { * Gets the event. * * @param executor the executor - * @return the event + * @return true , if the event exists */ public boolean getEvent(final TaskExecutionContext executor) { String idString = executor.subject.getId(); executor.logger.debug(idString); - + String albumNameString = executor.getContextAlbum("GlobalContextAlbum").getName(); executor.logger.debug(albumNameString); - + String inFieldsString = executor.inFields.toString(); executor.logger.debug(inFieldsString); - final Random rand = new Random(); - - if (executor.inFields.containsKey("TestDecideCaseSelected")) { - executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); - executor.outFields.put("TestActStateTime", java.lang.System.nanoTime()); - } - else if (executor.inFields.containsKey("TestEstablishCaseSelected")) { - executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); - executor.outFields.put("TestDecideStateTime", java.lang.System.nanoTime()); + try { + SecureRandom rand = SecureRandom.getInstanceStrong(); + if (executor.inFields.containsKey("TestDecideCaseSelected")) { + executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestActStateTime", System.nanoTime()); + } else if (executor.inFields.containsKey("TestEstablishCaseSelected")) { + executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestDecideStateTime", System.nanoTime()); + } else if (executor.inFields.containsKey("TestMatchCaseSelected")) { + executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestEstablishStateTime", System.nanoTime()); + } else { + executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); + executor.outFields.put("TestMatchStateTime", System.nanoTime()); + } + } catch (NoSuchAlgorithmException e) { + executor.logger.error("Exception during Random number generation ", e); + return false; } - else if (executor.inFields.containsKey("TestMatchCaseSelected")) { - executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); - executor.outFields.put("TestEstablishStateTime", java.lang.System.nanoTime()); - } - else { - executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT)); - executor.outFields.put("TestMatchStateTime", java.lang.System.nanoTime()); - } - - return true; + return true; } } |