sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yms.app.ydt; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 21 | import static org.onosproject.yms.app.ydt.YdtTestUtils.booleanYdt; |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 22 | import static org.onosproject.yms.app.ydt.YdtTestUtils.validateLeafContents; |
| 23 | import static org.onosproject.yms.app.ydt.YdtTestUtils.validateNodeContents; |
| 24 | import static org.onosproject.yms.ydt.YdtContextOperationType.MERGE; |
| 25 | |
| 26 | public class YdtBooleanTest { |
| 27 | |
| 28 | /* |
| 29 | BOOLEAN |
| 30 | Positive scenario |
| 31 | input with in "booleanList" and false |
| 32 | */ |
| 33 | |
| 34 | /** |
| 35 | * Creates and validates boolean ydt covering different positive scenario. |
| 36 | */ |
| 37 | @Test |
| 38 | public void positiveTest() { |
| 39 | YangRequestWorkBench ydtBuilder = booleanYdt(); |
| 40 | validateTree(ydtBuilder); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Validates the given built ydt. |
| 45 | */ |
| 46 | private void validateTree(YangRequestWorkBench ydtBuilder) { |
| 47 | |
| 48 | // assign root node to ydtNode for validating purpose. |
| 49 | YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode(); |
| 50 | // Logical root node does not have operation type |
| 51 | validateNodeContents(ydtNode, "builtInType", null); |
| 52 | ydtNode = ydtNode.getFirstChild(); |
| 53 | validateNodeContents(ydtNode, "bool", MERGE); |
| 54 | ydtNode = ydtNode.getFirstChild(); |
| 55 | validateNodeContents(ydtNode, "booleanList", MERGE); |
| 56 | ydtNode = ydtNode.getFirstChild(); |
| 57 | validateLeafContents(ydtNode, "boolean", "true"); |
| 58 | ydtNode = ydtNode.getParent(); |
| 59 | ydtNode = ydtNode.getNextSibling(); |
| 60 | validateNodeContents(ydtNode, "booleanList", MERGE); |
| 61 | ydtNode = ydtNode.getFirstChild(); |
| 62 | validateLeafContents(ydtNode, "boolean", "false"); |
| 63 | } |
| 64 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame^] | 65 | //TODO negative scenario will be handled later |
| 66 | // /* |
| 67 | // Negative scenario |
| 68 | // |
| 69 | // input with in non zero value in case of "booleanList" |
| 70 | // input with zero value in case of false |
| 71 | // input with empty value in case of false |
| 72 | // */ |
| 73 | // |
| 74 | // /** |
| 75 | // * Tests all the negative scenario's for boolean data type. |
| 76 | // */ |
| 77 | // @Test |
| 78 | // public void negativeTest() { |
| 79 | // validateErrMsg("boolean", BOOLNS, "10", BOOL, "booleanList"); |
| 80 | // validateErrMsg("boolean", BOOLNS, "0", BOOL, "booleanList"); |
| 81 | // validateErrMsg("boolean", BOOLNS, "", BOOL, "booleanList"); |
| 82 | // validateErrMsg("boolean", BOOLNS, "-1", BOOL, "booleanList"); |
| 83 | // validateErrMsg("boolean", BOOLNS, "tru", BOOL, "booleanList"); |
| 84 | // validateErrMsg("boolean", BOOLNS, "boolean", BOOL, "booleanList"); |
| 85 | // } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 86 | } |