From 4d23287f72f42103521d2b7738e93e79532b0246 Mon Sep 17 00:00:00 2001 From: Pamela Dragosh Date: Fri, 15 Mar 2019 10:27:24 -0400 Subject: Fill in legacy JSON models Fill in the bodies of the guard and operational JSON models. Issue-ID: POLICY-1195 Change-Id: If15dd8fa89e7a2b9d823eab51ac0b0f8819dd9d4 Signed-off-by: Pamela Dragosh --- .../legacy/LegacyGuardPolicyTest.java | 51 ++++++++++++++++++++++ .../legacy/LegacyOperationalPolicyTest.java | 43 ++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java create mode 100644 models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java (limited to 'models-tosca/src/test/java/org') diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java new file mode 100644 index 000000000..fa082331a --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 AT&T Intellectual Property. 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.models.tosca.serialization.legacy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.Test; + +public class LegacyGuardPolicyTest { + + @Test + public void test() { + LegacyGuardPolicy guard = new LegacyGuardPolicy(); + assertNotNull(guard); + guard.setPolicyId("guard.frequency"); + assertEquals("guard.frequency", guard.getPolicyId()); + guard.setPolicyVersion("1"); + assertEquals("1", guard.getPolicyVersion()); + Map body = new HashMap<>(); + body.put("actor", "SO"); + List> content = new ArrayList<>(); + content.add(body); + guard.setContent(content); + assertEquals(1, guard.getContent().size()); + } + +} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java new file mode 100644 index 000000000..13da63247 --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 AT&T Intellectual Property. 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.models.tosca.serialization.legacy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LegacyOperationalPolicyTest { + + @Test + public void test() { + LegacyOperationalPolicy policy = new LegacyOperationalPolicy(); + assertNotNull(policy); + policy.setPolicyId("onap.scaleout"); + assertEquals("onap.scaleout", policy.getPolicyId()); + policy.setPolicyVersion("1"); + assertEquals("1", policy.getPolicyVersion()); + policy.setContent("controlLoop%3A%0A%20%20"); + assertTrue(policy.getContent().length() > 0); + } + +} -- cgit 1.2.3-korg