4d8301f4ea40768355d5eed5bec4c6eef44e90ca
[ccsdk/cds.git] /
1 /*\r
2  *  Copyright © 2017-2018 AT&T Intellectual Property.\r
3  *\r
4  *  Licensed under the Apache License, Version 2.0 (the "License");\r
5  *  you may not use this file except in compliance with the License.\r
6  *  You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  *  Unless required by applicable law or agreed to in writing, software\r
11  *  distributed under the License is distributed on an "AS IS" BASIS,\r
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  *  See the License for the specific language governing permissions and\r
14  *  limitations under the License.\r
15  */\r
16 \r
17 package org.onap.ccsdk.apps.controllerblueprints.resource.dict.service\r
18 \r
19 import org.junit.Assert\r
20 import org.junit.Test\r
21 import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException\r
22 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
23 import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
24 import org.slf4j.LoggerFactory\r
25 /**\r
26  * ResourceAssignmentValidationServiceTest.\r
27  *\r
28  * @author Brinda Santh\r
29  */\r
30 class ResourceAssignmentValidationServiceTest {\r
31     private val log = LoggerFactory.getLogger(ResourceAssignmentValidationServiceTest::class.java)\r
32     @Test\r
33     fun testValidateSuccess() {\r
34         log.info("**************** testValidateSuccess *****************")\r
35         val assignments = JacksonUtils.getListFromClassPathFile("validation/success.json", ResourceAssignment::class.java)\r
36         val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
37         val result = resourceAssignmentValidator.validate(assignments!!)\r
38         Assert.assertTrue("Failed to Validate", result)\r
39     }\r
40 \r
41     @Test(expected = BluePrintException::class)\r
42     fun testValidateDuplicate() {\r
43         log.info(" **************** testValidateDuplicate *****************")\r
44         val assignments = JacksonUtils.getListFromClassPathFile("validation/duplicate.json", ResourceAssignment::class.java)\r
45         val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
46         resourceAssignmentValidator.validate(assignments!!)\r
47     }\r
48 \r
49     @Test(expected = BluePrintException::class)\r
50     fun testValidateCyclic() {\r
51         log.info(" ****************  testValidateCyclic *****************")\r
52         val assignments = JacksonUtils.getListFromClassPathFile("validation/cyclic.json", ResourceAssignment::class.java)\r
53         val resourceAssignmentValidator = ResourceAssignmentValidationDefaultService()\r
54         resourceAssignmentValidator.validate(assignments!!)\r
55     }\r
56 }