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.model.basicmodel.service;
24 import static org.assertj.core.api.Assertions.assertThatThrownBy;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
29 import org.junit.Test;
30 import org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation;
31 import org.onap.policy.apex.model.basicmodel.handling.DummyApexBasicModelCreator;
33 public class ModelServiceTest {
36 public void testModelService() {
39 assertFalse(ModelService.existsModel(AxKeyInformation.class));
40 assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
41 .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
42 + "not found in model service");
43 ModelService.registerModel(AxKeyInformation.class,
44 new DummyApexBasicModelCreator().getModel().getKeyInformation());
45 assertTrue(ModelService.existsModel(AxKeyInformation.class));
46 assertNotNull(ModelService.getModel(AxKeyInformation.class));
48 ModelService.deregisterModel(AxKeyInformation.class);
50 assertFalse(ModelService.existsModel(AxKeyInformation.class));
51 assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
52 .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
53 + "not found in model service");
54 ModelService.registerModel(AxKeyInformation.class,
55 new DummyApexBasicModelCreator().getModel().getKeyInformation());
56 assertTrue(ModelService.existsModel(AxKeyInformation.class));
57 assertNotNull(ModelService.getModel(AxKeyInformation.class));
60 assertFalse(ModelService.existsModel(AxKeyInformation.class));
61 assertThatThrownBy(() -> ModelService.getModel(AxKeyInformation.class))
62 .hasMessage("Model for org.onap.policy.apex.model.basicmodel.concepts.AxKeyInformation "
63 + "not found in model service");