2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.examples.adaptive;
23 import static org.junit.Assert.assertTrue;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult;
28 import org.onap.policy.apex.model.basicmodel.dao.DaoParameters;
29 import org.onap.policy.apex.model.basicmodel.test.TestApexModel;
30 import org.onap.policy.apex.model.policymodel.concepts.AxPolicyModel;
32 public class AnomalyDetectionModelTest {
33 TestApexModel<AxPolicyModel> testApexModel;
36 * Sets up embedded Derby database and the Apex anomaly detection model for the tests.
37 * @throws Exception exception to be thrown while setting up the database connection
40 public void setup() throws Exception {
41 testApexModel = new TestApexModel<>(AxPolicyModel.class, new TestAnomalyDetectionModelCreator());
45 public void testModelValid() throws Exception {
46 final AxValidationResult result = testApexModel.testApexModelValid();
47 assertTrue(result.toString().equals(VALID_MODEL_STRING));
51 public void testModelWriteReadXml() throws Exception {
52 testApexModel.testApexModelWriteReadXml();
56 public void testModelWriteReadJson() throws Exception {
57 testApexModel.testApexModelWriteReadJson();
61 public void testModelWriteReadJpa() throws Exception {
62 final DaoParameters DaoParameters = new DaoParameters();
63 DaoParameters.setPluginClass("org.onap.policy.apex.model.basicmodel.dao.impl.DefaultApexDao");
64 DaoParameters.setPersistenceUnit("AdaptiveModelsTest");
66 testApexModel.testApexModelWriteReadJpa(DaoParameters);
69 private static final String VALID_MODEL_STRING = "***validation of model successful***";