import java.util.Map.Entry;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
+import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.utilities.TextFileUtils;
import org.onap.policy.apex.service.engine.engdep.EngDepMessagingService;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.parameters.ApexParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
engineServiceHandler.terminate();
engineServiceHandler = null;
}
+
+ // Clear the services
+ ModelService.clear();
+ ParameterService.clear();
}
/**
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJRUBY.xml",
+ "engineParameters": {
+ "executorParameters": {
+ "JRUBY": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.jruby.JrubyExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/GetEvents"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/PostEvent"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJAVA.xml",
+ "engineParameters": {
+ "executorParameters": {
+ "JAVA": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.java.JavaExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/GetEvents"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/PostEvent"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
"carrierTechnology": "RESTCLIENT",
"parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
"parameters": {
- "url": "http://localhost:32801/TestRest2REST/apex/event/GetEvent"
+ "url": "http://localhost:32801/EventGenerator/GetEvents"
}
},
"eventProtocolParameters": {
"carrierTechnology": "RESTCLIENT",
"parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
"parameters": {
- "url": "http://localhost:32801/TestRest2REST/apex/event/PostEvent"
+ "url": "http://localhost:32801/EventGenerator/PostEvent"
}
},
"eventProtocolParameters": {
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelJYTHON.xml",
+ "engineParameters": {
+ "executorParameters": {
+ "JYTHON": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.jython.JythonExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/GetEvents"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/PostEvent"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
--- /dev/null
+{
+ "engineServiceParameters": {
+ "name": "MyApexEngine",
+ "version": "0.0.1",
+ "id": 45,
+ "instanceCount": 4,
+ "deploymentPort": 12561,
+ "policyModelFileName": "examples/models/SampleDomain/SamplePolicyModelMVEL.xml",
+ "engineParameters": {
+ "executorParameters": {
+ "MVEL": {
+ "parameterClassName": "org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters"
+ }
+ }
+ }
+ },
+ "eventInputParameters": {
+ "FirstConsumer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/GetEvents"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ },
+ "eventOutputParameters": {
+ "FirstProducer": {
+ "carrierTechnologyParameters": {
+ "carrierTechnology": "RESTCLIENT",
+ "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restclient.RestClientCarrierTechnologyParameters",
+ "parameters": {
+ "url": "http://localhost:32801/EventGenerator/PostEvent"
+ }
+ },
+ "eventProtocolParameters": {
+ "eventProtocol": "JSON"
+ }
+ }
+ }
+}
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.apex-pdp.plugins.plugins-executor</groupId>
+ <artifactId>plugins-executor-mvel</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.onap.policy.apex-pdp.plugins.plugins-context.plugins-context-distribution</groupId>
<artifactId>plugins-context-distribution-infinispan</artifactId>
* The Class TestKafka2Kafka tests Kafka event sending and reception.
*/
public class TestKafka2Kafka {
- private static final long MAX_TEST_LENGTH = 60000;
+ private static final long MAX_TEST_LENGTH = 300000;
- private static final int EVENT_COUNT = 100;
+ private static final int EVENT_COUNT = 25;
private static final int EVENT_INTERVAL = 20;
/**
ThreadUtilities.sleep(EVENT_INTERVAL);
}
- ThreadUtilities.sleep(1000);
+ ThreadUtilities.sleep(3000);
apexMain.shutdown();
subscriber.shutdown();
Response response = null;
// Wait for the required amount of events to be received or for 10 seconds
- for (int i = 0; i < 100; i++) {
- ThreadUtilities.sleep(100);
+ for (int i = 0; i < 20; i++) {
+ ThreadUtilities.sleep(300);
response = client.target("http://localhost:32801/TestFile2Rest/apex/event/Stats")
.request("application/json").get();
@SuppressWarnings("unchecked")
final Map<String, Object> jsonMap = new Gson().fromJson(responseString, Map.class);
- if ((double) jsonMap.get("PUT") == 100) {
+ if ((double) jsonMap.get("PUT") == 20) {
break;
}
}
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.performance.benchmark.engine.runtime;
+package org.onap.policy.apex.testsuites.integration.uservice.engine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.context.parameters.LockManagerParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.core.engine.EngineParameterConstants;
+import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
-import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
private AxPolicyModel apexSamplePolicyModel = null;
private String apexSampleModelString;
+ /**
+ * Set up parameters.
+ */
+ @Before
+ public void setupParameters() {
+ ParameterService.register(new SchemaParameters());
+ ParameterService.register(new ContextParameters());
+ ParameterService.register(new DistributorParameters());
+ ParameterService.register(new LockManagerParameters());
+ ParameterService.register(new PersistorParameters());
+ ParameterService.register(new EngineServiceParameters());
+
+ EngineParameters engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ /**
+ * Clear down parameters.
+ */
+ @After
+ public void teardownParameters() {
+ ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
/**
* Sets up the test by creating an engine and reading in the test policy.
*
LOGGER.debug("Running TestApexEngine. . .");
- apexSamplePolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ apexSamplePolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
assertNotNull(apexSamplePolicyModel);
- apexSampleModelString = Utils.getModelString(apexSamplePolicyModel);
+ apexSampleModelString = getModelString(apexSamplePolicyModel);
// create engine
listener = new TestListener();
@Test
public void testModelUpdateStringNewNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
- service.startAll();
+
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
}
@Test
public void testModelUpdateStringNewForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, true);
- service.startAll();
+
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
}
@Test
public void testModelUpdateStringNewNewNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSampleModelString, false);
- service.startAll();
+
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
sendEvents();
@Test
public void testModelUpdateIncoNoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
- service.startAll();
+
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
// Different model name, incompatible
} catch (final Exception e) {
System.err.println(e.getMessage());
assertEquals("apex model update failed, supplied model with key \"INCOMPATIBLE:0.0.1\" is not a compatible "
- + "model update from the existing engine model with key \"SamplePolicyModelMVEL:0.0.1\"",
- e.getMessage());
+ + "model update from the existing engine model "
+ + "with key \"SamplePolicyModelJAVASCRIPT:0.0.1\"", e.getMessage());
}
// Still on old model
} catch (final Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
- assertEquals("apex model update failed, supplied model with key \"SamplePolicyModelMVEL:1.0.1\" is not "
- + "a compatible model update from the existing engine model with key "
- + "\"SamplePolicyModelMVEL:0.0.1\"", e.getMessage());
+ assertEquals("apex model update failed, supplied model with key \"SamplePolicyModelJAVASCRIPT:1.0.1\" "
+ + "is not a compatible model update from the existing engine model with key "
+ + "\"SamplePolicyModelJAVASCRIPT:0.0.1\"", e.getMessage());
}
// Still on old model
@Test
public void testModelUpdateIncoForce() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexSamplePolicyModel, false);
- service.startAll();
+
assertEquals(apexSamplePolicyModel.getKey(), ModelService.getModel(AxPolicyModel.class).getKey());
// Different model name, incompatible
&& ((byte) result.get("TestActCaseSelected") <= 3));
}
}
+
+
+ /**
+ * Gets the model string.
+ *
+ * @param policyModel the eca policy model
+ * @return the model string
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ private String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
+ try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
+ new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+ return baOutputStream.toString();
+ }
+ }
}
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.apex.testsuites.performance.benchmark.engine.runtime;
+package org.onap.policy.apex.testsuites.integration.uservice.engine;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import org.junit.After;
import org.junit.AfterClass;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.apex.context.parameters.ContextParameterConstants;
+import org.onap.policy.apex.context.parameters.ContextParameters;
+import org.onap.policy.apex.context.parameters.DistributorParameters;
+import org.onap.policy.apex.context.parameters.LockManagerParameters;
+import org.onap.policy.apex.context.parameters.PersistorParameters;
+import org.onap.policy.apex.context.parameters.SchemaParameters;
+import org.onap.policy.apex.core.engine.EngineParameterConstants;
+import org.onap.policy.apex.core.engine.EngineParameters;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
+import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
+import org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters;
import org.onap.policy.apex.plugins.executor.mvel.MvelExecutorParameters;
import org.onap.policy.apex.service.engine.event.ApexEvent;
import org.onap.policy.apex.service.engine.runtime.ApexEventListener;
import org.onap.policy.apex.service.engine.runtime.EngineService;
import org.onap.policy.apex.service.engine.runtime.EngineServiceEventInterface;
import org.onap.policy.apex.service.engine.runtime.impl.EngineServiceImpl;
+import org.onap.policy.apex.service.parameters.ApexParameterConstants;
import org.onap.policy.apex.service.parameters.engineservice.EngineServiceParameters;
import org.onap.policy.apex.testsuites.integration.common.model.SampleDomainModelFactory;
-import org.onap.policy.apex.testsuites.performance.benchmark.engine.utils.Utils;
+import org.onap.policy.common.parameters.ParameterService;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
LOGGER.debug("Running TestApexEngine. . .");
- apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("MVEL");
+ apexPolicyModel = new SampleDomainModelFactory().getSamplePolicyModel("JAVASCRIPT");
assertNotNull(apexPolicyModel);
- apexModelString = Utils.getModelString(apexPolicyModel);
+ apexModelString = getModelString(apexPolicyModel);
// create engine
listener = new TestListener();
service.registerActionListener("Listener", listener);
}
+ /**
+ * Set up parameters.
+ */
+ @Before
+ public void setupParameters() {
+ ParameterService.register(new SchemaParameters());
+ ParameterService.register(new ContextParameters());
+ ParameterService.register(new DistributorParameters());
+ ParameterService.register(new LockManagerParameters());
+ ParameterService.register(new PersistorParameters());
+ ParameterService.register(new EngineServiceParameters());
+
+ EngineParameters engineParameters = new EngineParameters();
+ engineParameters.getExecutorParameterMap().put("JAVASCRIPT", new JavascriptExecutorParameters());
+ ParameterService.register(engineParameters);
+ }
+
+ /**
+ * Clear down parameters.
+ */
+ @After
+ public void teardownParameters() {
+ ParameterService.deregister(EngineParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.deregister(ApexParameterConstants.ENGINE_SERVICE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.PERSISTENCE_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.LOCKING_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.DISTRIBUTOR_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.MAIN_GROUP_NAME);
+ ParameterService.deregister(ContextParameterConstants.SCHEMA_GROUP_NAME);
+ }
+
/**
* Update the engine then test the engine with 2 sample events.
*
@Test
public void testExecutionSet1() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
- // Start the service
- service.startAll();
+
final long starttime = System.currentTimeMillis();
for (final AxArtifactKey engineKey : service.getEngineKeys()) {
LOGGER.info("{}", service.getStatus(engineKey));
@Test
public void testExecutionSet1Sync() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
- // Start the service
- service.startAll();
+
final long starttime = System.currentTimeMillis();
for (final AxArtifactKey engineKey : service.getEngineKeys()) {
LOGGER.info("{}", service.getStatus(engineKey));
@Test
public void testExecutionSet2() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
- // Start the service
- service.startAll();
+
final long starttime = System.currentTimeMillis();
for (final AxArtifactKey engineKey : service.getEngineKeys()) {
LOGGER.info("{}", service.getStatus(engineKey));
@Test
public void testExecutionSet2Sync() throws ApexException {
service.updateModel(parameters.getEngineKey(), apexModelString, true);
- // Start the service
- service.startAll();
+
final long starttime = System.currentTimeMillis();
for (final AxArtifactKey engineKey : service.getEngineKeys()) {
LOGGER.info("{}", service.getStatus(engineKey));
((byte) result.get("TestActCaseSelected")) >= 0 && ((byte) result.get("TestActCaseSelected") <= 3));
}
}
+
+ /**
+ * Gets the model string.
+ *
+ * @param policyModel the eca policy model
+ * @return the model string
+ * @throws ApexModelException the apex model exception
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ private static String getModelString(final AxPolicyModel policyModel) throws ApexModelException, IOException {
+ try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
+ new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(policyModel, baOutputStream);
+ return baOutputStream.toString();
+ }
+ }
}
+++ /dev/null
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2018 Ericsson. All rights reserved.
- * ================================================================================
- * 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.performance.benchmark.engine.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelException;
-import org.onap.policy.apex.model.basicmodel.handling.ApexModelWriter;
-import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
-
-/**
- * The Class Utils.
- */
-public class Utils {
-
- /**
- * Instantiates a new utils.
- */
- private Utils() {}
-
- /**
- * Gets the model string.
- *
- * @param ecaPolicyModel the eca policy model
- * @return the model string
- * @throws ApexModelException the apex model exception
- * @throws IOException Signals that an I/O exception has occurred.
- */
- public static String getModelString(final AxPolicyModel ecaPolicyModel) throws ApexModelException, IOException {
- try (final ByteArrayOutputStream baOutputStream = new ByteArrayOutputStream()) {
- new ApexModelWriter<AxPolicyModel>(AxPolicyModel.class).write(ecaPolicyModel, baOutputStream);
- return baOutputStream.toString();
- }
- }
-
-}