2 * ============LICENSE_START=======================================================
3 * policy-yaml unit test
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.compiler;
23 import static org.junit.Assert.fail;
26 import java.io.FileInputStream;
27 import java.io.FileNotFoundException;
28 import java.io.IOException;
29 import java.io.InputStream;
31 import org.junit.Test;
33 import org.onap.policy.controlloop.guard.compiler.ControlLoopGuardCompiler;
35 public class ControlLoopGuardCompilerTest {
38 public void testTest1() {
40 this.test("src/test/resources/v2.0.0-guard/policy_guard_vUSP_1707_appc.yaml");
41 } catch (Exception e) {
47 public void testBad1() {
49 this.test("src/test/resources/v2.0.0-guard/no_guard_policy.yaml");
50 } catch (Exception e) {
56 public void testBad2() {
58 this.test("src/test/resources/v2.0.0-guard/duplicate_guard_policy.yaml");
59 } catch (Exception e) {
65 public void testBad3() {
67 this.test("src/test/resources/v2.0.0-guard/no_guard_constraint.yaml");
68 } catch (Exception e) {
74 public void testBad4() {
76 this.test("src/test/resources/v2.0.0-guard/duplicate_guard_constraint.yaml");
77 } catch (Exception e) {
82 public void test(String testFile) throws Exception {
83 try (InputStream is = new FileInputStream(new File(testFile))) {
84 ControlLoopGuardCompiler.compile(is, null);
85 } catch (FileNotFoundException e) {
87 } catch (IOException e) {
89 } catch (Exception e) {