sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 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.bitYdt; |
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 YdtBitTest { |
| 27 | |
| 28 | /* |
| 29 | BINARY |
| 30 | |
| 31 | Positive scenario |
| 32 | input with position 0 |
| 33 | input with position 1 |
| 34 | input with position 2 |
| 35 | */ |
| 36 | |
| 37 | /** |
| 38 | * Creates and validates bit ydt covering different positive scenario. |
| 39 | */ |
| 40 | @Test |
| 41 | public void positiveTest() { |
| 42 | YangRequestWorkBench ydtBuilder = bitYdt(); |
| 43 | validateTree(ydtBuilder); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Validates the given built ydt. |
| 48 | */ |
| 49 | private void validateTree(YangRequestWorkBench ydtBuilder) { |
| 50 | |
| 51 | // assign root node to ydtNode for validating purpose. |
| 52 | YdtNode ydtNode = (YdtNode) ydtBuilder.getRootNode(); |
| 53 | // Logical root node does not have operation type |
| 54 | validateNodeContents(ydtNode, "builtInType", null); |
| 55 | ydtNode = ydtNode.getFirstChild(); |
| 56 | validateNodeContents(ydtNode, "bit", MERGE); |
| 57 | ydtNode = ydtNode.getFirstChild(); |
| 58 | validateNodeContents(ydtNode, "bitList", MERGE); |
| 59 | ydtNode = ydtNode.getFirstChild(); |
| 60 | validateLeafContents(ydtNode, "bit", "disable-nagle"); |
| 61 | ydtNode = ydtNode.getParent(); |
| 62 | ydtNode = ydtNode.getNextSibling(); |
| 63 | validateNodeContents(ydtNode, "bitList", MERGE); |
| 64 | ydtNode = ydtNode.getFirstChild(); |
| 65 | validateLeafContents(ydtNode, "bit", "auto-sense-speed"); |
| 66 | ydtNode = ydtNode.getParent(); |
| 67 | ydtNode = ydtNode.getNextSibling(); |
| 68 | validateNodeContents(ydtNode, "bitList", MERGE); |
| 69 | ydtNode = ydtNode.getFirstChild(); |
| 70 | validateLeafContents(ydtNode, "bit", "ten-Mb-only"); |
| 71 | } |
| 72 | |
sonu gupta | eff184b | 2016-11-24 12:43:49 +0530 | [diff] [blame] | 73 | //TODO negative scenario will be handled later |
| 74 | // /* |
| 75 | // Negative scenario |
| 76 | // |
| 77 | // input with position 0 |
| 78 | // input with position 1 |
| 79 | // input with position 2 |
| 80 | // */ |
| 81 | // |
| 82 | // /** |
| 83 | // * Tests all the negative scenario's for bit data type. |
| 84 | // */ |
| 85 | // @Test |
| 86 | // public void negativeTest() { |
| 87 | // validateErrMsg("bit", BITNS, "0", BIT, "bitList"); |
| 88 | // validateErrMsg("bit", BITNS, "default", BIT, "bitList"); |
| 89 | // validateErrMsg("bit", BITNS, "1", BIT, "bitList"); |
| 90 | // validateErrMsg("bit", BITNS, "", BIT, "bitList"); |
| 91 | // } |
sonu gupta | 1bb37b8 | 2016-11-11 16:51:18 +0530 | [diff] [blame] | 92 | } |