2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2020 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.testsuites.integration.common.model.java;
24 import java.util.Random;
26 import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext;
29 * The Class DefaultTask_Logic is default task logic in Java.
31 public class DefaultTaskLogic {
32 private static final int BOUND_FOR_RANDOM_INT = 4;
33 private static final Random rand = new Random();
38 * @param executor the executor
41 public boolean getEvent(final TaskExecutionContext executor) {
42 String idString = executor.subject.getId();
43 executor.logger.debug(idString);
45 String albumNameString = executor.getContextAlbum("GlobalContextAlbum").getName();
46 executor.logger.debug(albumNameString);
48 String inFieldsString = executor.inFields.toString();
49 executor.logger.debug(inFieldsString);
50 if (executor.inFields.containsKey("TestDecideCaseSelected")) {
51 executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
52 executor.outFields.put("TestActStateTime", System.nanoTime());
53 } else if (executor.inFields.containsKey("TestEstablishCaseSelected")) {
54 executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
55 executor.outFields.put("TestDecideStateTime", System.nanoTime());
56 } else if (executor.inFields.containsKey("TestMatchCaseSelected")) {
57 executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
58 executor.outFields.put("TestEstablishStateTime", System.nanoTime());
60 executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
61 executor.outFields.put("TestMatchStateTime", System.nanoTime());