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;
25 import org.onap.policy.apex.core.engine.executor.context.TaskExecutionContext;
28 * The Class DefaultTask_Logic is default task logic in Java.
30 public class DefaultTaskLogic {
31 private static final int BOUND_FOR_RANDOM_INT = 4;
32 private static final Random rand = new Random();
37 * @param executor the executor
40 public boolean getEvent(final TaskExecutionContext executor) {
41 String idString = executor.subject.getId();
42 executor.logger.debug(idString);
44 String albumNameString = executor.getContextAlbum("GlobalContextAlbum").getName();
45 executor.logger.debug(albumNameString);
47 String inFieldsString = executor.inFields.toString();
48 executor.logger.debug(inFieldsString);
49 if (executor.inFields.containsKey("TestDecideCaseSelected")) {
50 executor.outFields.put("TestActCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
51 executor.outFields.put("TestActStateTime", System.nanoTime());
52 } else if (executor.inFields.containsKey("TestEstablishCaseSelected")) {
53 executor.outFields.put("TestDecideCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
54 executor.outFields.put("TestDecideStateTime", System.nanoTime());
55 } else if (executor.inFields.containsKey("TestMatchCaseSelected")) {
56 executor.outFields.put("TestEstablishCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
57 executor.outFields.put("TestEstablishStateTime", System.nanoTime());
59 executor.outFields.put("TestMatchCaseSelected", (byte) rand.nextInt(BOUND_FOR_RANDOM_INT));
60 executor.outFields.put("TestMatchStateTime", System.nanoTime());