Bharat saraswal | b1170bd | 2016-07-14 13:26:18 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | * use this file except in compliance with the License. You may obtain a copy of |
| 6 | * 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, WITHOUT |
| 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | * License for the specific language governing permissions and limitations under |
| 14 | * the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.yangutils.plugin.manager; |
| 18 | |
| 19 | import java.io.IOException; |
| 20 | import java.util.List; |
| 21 | |
| 22 | import org.apache.maven.plugin.MojoExecutionException; |
| 23 | import org.junit.Test; |
| 24 | import org.onosproject.yangutils.datamodel.ResolvableType; |
| 25 | import org.onosproject.yangutils.datamodel.YangAugment; |
| 26 | import org.onosproject.yangutils.datamodel.YangNode; |
| 27 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
| 28 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; |
| 29 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
| 30 | import org.onosproject.yangutils.linker.impl.YangXpathLinker; |
| 31 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
| 32 | |
| 33 | import static org.hamcrest.MatcherAssert.assertThat; |
| 34 | import static org.hamcrest.core.Is.is; |
| 35 | |
| 36 | /** |
| 37 | * Unit test cases for x-path linker. |
| 38 | */ |
| 39 | public class YangXpathLinkerTest { |
| 40 | |
| 41 | private YangUtilManager utilManager = new YangUtilManager(); |
| 42 | private YangXpathLinker linker = new YangXpathLinker(); |
| 43 | private YangLinkerManager linkerManager = new YangLinkerManager(); |
| 44 | private static final String INTRA_FILE_PATH = "src/test/resources/xPathLinker/IntraFile/"; |
| 45 | private static final String INTER_FILE_PATH = "src/test/resources/xPathLinker/InterFile/"; |
| 46 | |
| 47 | /** |
| 48 | * Unit test case for intra file linking for single level container. |
| 49 | * |
| 50 | * @throws IOException when fails to do IO operations |
| 51 | * @throws MojoExecutionException |
| 52 | */ |
| 53 | @Test |
| 54 | public void processIntraFileLinkingSingleLevel() throws IOException, MojoExecutionException { |
| 55 | |
| 56 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingle/")); |
| 57 | utilManager.parseYangFileInfoSet(); |
| 58 | utilManager.createYangNodeSet(); |
| 59 | utilManager.resolveDependenciesUsingLinker(); |
| 60 | |
| 61 | YangNode targetNode = null; |
| 62 | String targetNodeName = null; |
| 63 | |
| 64 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 65 | YangReferenceResolver ref = (YangReferenceResolver) node; |
| 66 | List<YangResolutionInfo> infos = ref.getUnresolvedResolutionList(ResolvableType.YANG_AUGMENT); |
| 67 | YangResolutionInfo info = infos.get(0); |
| 68 | |
| 69 | YangAugment augment = (YangAugment) info.getEntityToResolveInfo().getEntityToResolve(); |
| 70 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 71 | .getName(); |
| 72 | targetNode = augment.getAugmentedNode(); |
| 73 | |
| 74 | } |
| 75 | |
| 76 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Unit test case for intra file linking for multiple level container. |
| 81 | * |
| 82 | * @throws IOException when fails to do IO operations |
| 83 | */ |
| 84 | @Test |
| 85 | public void processIntraFileLinkingMultipleLevel() throws IOException { |
| 86 | |
| 87 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMulti/")); |
| 88 | utilManager.parseYangFileInfoSet(); |
| 89 | utilManager.createYangNodeSet(); |
| 90 | |
| 91 | YangNode targetNode = null; |
| 92 | String targetNodeName = null; |
| 93 | |
| 94 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 95 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 96 | |
| 97 | for (YangAugment augment : augments) { |
| 98 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 99 | .getName(); |
| 100 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Unit test case for intra file linking for single level augment. |
| 109 | * |
| 110 | * @throws IOException when fails to do IO operations |
| 111 | */ |
| 112 | @Test |
| 113 | public void processIntraFileLinkingInAugmentSingleLevel() throws IOException { |
| 114 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleAugment/")); |
| 115 | utilManager.parseYangFileInfoSet(); |
| 116 | utilManager.createYangNodeSet(); |
| 117 | |
| 118 | YangNode targetNode = null; |
| 119 | String targetNodeName = null; |
| 120 | |
| 121 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 122 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 123 | |
| 124 | for (YangAugment augment : augments) { |
| 125 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 126 | .getName(); |
| 127 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Unit test case for intra file linking for multiple level augment. |
| 136 | * |
| 137 | * @throws IOException when fails to do IO operations |
| 138 | */ |
| 139 | @Test |
| 140 | public void processIntraFileLinkingInAugmentMultiLevel() throws IOException { |
| 141 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiAugment/")); |
| 142 | utilManager.parseYangFileInfoSet(); |
| 143 | utilManager.createYangNodeSet(); |
| 144 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 145 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 146 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 147 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 148 | |
| 149 | YangNode targetNode = null; |
| 150 | String targetNodeName = null; |
| 151 | |
| 152 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 153 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 154 | |
| 155 | for (YangAugment augment : augments) { |
| 156 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 157 | .getName(); |
| 158 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 163 | |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Unit test case for intra file linking for multiple level submodule. |
| 168 | * |
| 169 | * @throws IOException when fails to do IO operations |
| 170 | */ |
| 171 | @Test |
| 172 | public void processIntraFileLinkingInSubModuleSingleLevel() throws IOException { |
| 173 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleSubModule/")); |
| 174 | utilManager.parseYangFileInfoSet(); |
| 175 | utilManager.createYangNodeSet(); |
| 176 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 177 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
| 178 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 179 | |
| 180 | YangNode targetNode = null; |
| 181 | String targetNodeName = null; |
| 182 | |
| 183 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 184 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 185 | |
| 186 | for (YangAugment augment : augments) { |
| 187 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 188 | .getName(); |
| 189 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Unit test case for intra file linking for multiple level submodule. |
| 198 | * |
| 199 | * @throws IOException when fails to do IO operations |
| 200 | */ |
| 201 | @Test |
| 202 | public void processIntraFileLinkingInSubModuleMultiLevel() throws IOException { |
| 203 | |
| 204 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiSubModule/")); |
| 205 | utilManager.parseYangFileInfoSet(); |
| 206 | utilManager.createYangNodeSet(); |
| 207 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 208 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
| 209 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 210 | |
| 211 | YangNode targetNode = null; |
| 212 | String targetNodeName = null; |
| 213 | |
| 214 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 215 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 216 | |
| 217 | for (YangAugment augment : augments) { |
| 218 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 219 | .getName(); |
| 220 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Unit test case for intra file linking for single level uses. |
| 229 | * |
| 230 | * @throws IOException when fails to do IO operations |
| 231 | */ |
| 232 | @Test |
| 233 | public void processIntraFileLinkingInUsesSingleLevel() throws IOException { |
| 234 | |
| 235 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/")); |
| 236 | utilManager.parseYangFileInfoSet(); |
| 237 | utilManager.createYangNodeSet(); |
| 238 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 239 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 240 | |
| 241 | YangNode targetNode = null; |
| 242 | String targetNodeName = null; |
| 243 | |
| 244 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 245 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 246 | |
| 247 | for (YangAugment augment : augments) { |
| 248 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 249 | .getName(); |
| 250 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * Unit test case for intra file linking for multi level uses. |
| 259 | * |
| 260 | * @throws IOException when fails to do IO operations |
| 261 | */ |
| 262 | @Test |
| 263 | public void processIntraFileLinkingInUsesMultiLevel() throws IOException { |
| 264 | |
| 265 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/")); |
| 266 | utilManager.parseYangFileInfoSet(); |
| 267 | utilManager.createYangNodeSet(); |
| 268 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 269 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 270 | |
| 271 | YangNode targetNode = null; |
| 272 | String targetNodeName = null; |
| 273 | |
| 274 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 275 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 276 | |
| 277 | for (YangAugment augment : augments) { |
| 278 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 279 | .getName(); |
| 280 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Unit test case for inter file linking for single level container. |
| 289 | * |
| 290 | * @throws IOException when fails to do IO operations |
| 291 | */ |
| 292 | @Test |
| 293 | public void processInterFileLinkingSingleLevel() throws IOException { |
| 294 | |
| 295 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingle/")); |
| 296 | utilManager.parseYangFileInfoSet(); |
| 297 | utilManager.createYangNodeSet(); |
| 298 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 299 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 300 | |
| 301 | YangNode targetNode = null; |
| 302 | String targetNodeName = null; |
| 303 | |
| 304 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 305 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 306 | |
| 307 | for (YangAugment augment : augments) { |
| 308 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 309 | .getName(); |
| 310 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * Unit test case for inter file linking for multi level container. |
| 319 | * |
| 320 | * @throws IOException when fails to do IO operations |
| 321 | */ |
| 322 | @Test |
| 323 | public void processInterFileLinkingMultipleLevel() throws IOException { |
| 324 | |
| 325 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMulti/")); |
| 326 | utilManager.parseYangFileInfoSet(); |
| 327 | utilManager.createYangNodeSet(); |
| 328 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 329 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 330 | |
| 331 | YangNode targetNode = null; |
| 332 | String targetNodeName = null; |
| 333 | |
| 334 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 335 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 336 | |
| 337 | for (YangAugment augment : augments) { |
| 338 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 339 | .getName(); |
| 340 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 345 | } |
| 346 | |
| 347 | /** |
| 348 | * Unit test case for inter file linking for single level augment. |
| 349 | * |
| 350 | * @throws IOException when fails to do IO operations |
| 351 | */ |
| 352 | @Test |
| 353 | public void processInterFileLinkingInAugmentSingleLevel() throws IOException { |
| 354 | |
| 355 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleAugment/")); |
| 356 | utilManager.parseYangFileInfoSet(); |
| 357 | utilManager.createYangNodeSet(); |
| 358 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 359 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 360 | |
| 361 | YangNode targetNode = null; |
| 362 | String targetNodeName = null; |
| 363 | |
| 364 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 365 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 366 | |
| 367 | for (YangAugment augment : augments) { |
| 368 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 369 | .getName(); |
| 370 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Unit test case for inter file linking for multi level augment. |
| 379 | * |
| 380 | * @throws IOException when fails to do IO operations |
| 381 | */ |
| 382 | @Test |
| 383 | public void processInterFileLinkingInAugmentMultiLevel() throws IOException { |
| 384 | |
| 385 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiAugment/")); |
| 386 | utilManager.parseYangFileInfoSet(); |
| 387 | utilManager.createYangNodeSet(); |
| 388 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 389 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 390 | |
| 391 | YangNode targetNode = null; |
| 392 | String targetNodeName = null; |
| 393 | |
| 394 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 395 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 396 | |
| 397 | for (YangAugment augment : augments) { |
| 398 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 399 | .getName(); |
| 400 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Unit test case for multipler inter file linking for single level augment. |
| 409 | * |
| 410 | * @throws IOException when fails to do IO operations |
| 411 | */ |
| 412 | @Test |
| 413 | public void processMultiInterFileLinkingInAugmentSingleLevel() throws IOException { |
| 414 | |
| 415 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugment/")); |
| 416 | utilManager.parseYangFileInfoSet(); |
| 417 | utilManager.createYangNodeSet(); |
| 418 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 419 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 420 | |
| 421 | YangNode targetNode = null; |
| 422 | String targetNodeName = null; |
| 423 | |
| 424 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 425 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 426 | |
| 427 | for (YangAugment augment : augments) { |
| 428 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 429 | .getName(); |
| 430 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Unit test case for multiple inter file linking for multi level augment. |
| 439 | * |
| 440 | * @throws IOException when fails to do IO operations |
| 441 | */ |
| 442 | @Test |
| 443 | public void processMultiInterFileLinkingInAugmentMultiLevel() throws IOException { |
| 444 | |
| 445 | utilManager |
| 446 | .createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiFileAugmentMulti/")); |
| 447 | utilManager.parseYangFileInfoSet(); |
| 448 | utilManager.createYangNodeSet(); |
| 449 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 450 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 451 | |
| 452 | YangNode targetNode = null; |
| 453 | String targetNodeName = null; |
| 454 | |
| 455 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 456 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 457 | |
| 458 | for (YangAugment augment : augments) { |
| 459 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 460 | .getName(); |
| 461 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 466 | } |
| 467 | |
| 468 | /** |
| 469 | * Unit test case for inter file linking for single level submodule. |
| 470 | * |
| 471 | * @throws IOException when fails to do IO operations |
| 472 | */ |
| 473 | @Test |
| 474 | public void processInterFileLinkingInSubModuleSingleLevel() throws IOException { |
| 475 | |
| 476 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleSubModule/")); |
| 477 | utilManager.parseYangFileInfoSet(); |
| 478 | utilManager.createYangNodeSet(); |
| 479 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 480 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
| 481 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 482 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 483 | |
| 484 | YangNode targetNode = null; |
| 485 | String targetNodeName = null; |
| 486 | |
| 487 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 488 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 489 | |
| 490 | for (YangAugment augment : augments) { |
| 491 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 492 | .getName(); |
| 493 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Unit test case for inter file linking for multi level submodule. |
| 502 | * |
| 503 | * @throws IOException when fails to do IO operations |
| 504 | */ |
| 505 | @Test |
| 506 | public void processInterFileLinkingInSubModuleMultiLevel() throws IOException { |
| 507 | |
| 508 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiSubModule/")); |
| 509 | utilManager.parseYangFileInfoSet(); |
| 510 | utilManager.createYangNodeSet(); |
| 511 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 512 | linkerManager.linkSubModulesToParentModule(utilManager.getYangNodeSet()); |
| 513 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 514 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 515 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 516 | YangNode targetNode = null; |
| 517 | String targetNodeName = null; |
| 518 | |
| 519 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 520 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 521 | |
| 522 | for (YangAugment augment : augments) { |
| 523 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 524 | .getName(); |
| 525 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 526 | } |
| 527 | } |
| 528 | |
| 529 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Unit test case for inter file linking for multi level uses inside augment. |
| 534 | * |
| 535 | * @throws IOException when fails to do IO operations |
| 536 | */ |
| 537 | @Test |
| 538 | public void processInterFileLinkingInUsesInAugment() throws IOException { |
| 539 | |
| 540 | /* FIXME: when uses cloning is done test it. |
| 541 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterSingleUses/")); |
| 542 | utilManager.parseYangFileInfoSet(); |
| 543 | utilManager.createYangNodeSet(); |
| 544 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 545 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 546 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 547 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 548 | |
| 549 | YangNode targetNode = null; |
| 550 | String targetNodeName = null; |
| 551 | |
| 552 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 553 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 554 | |
| 555 | for (YangAugment augment : augments) { |
| 556 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1) |
| 557 | .getNodeIdentifier().getName(); |
| 558 | targetNode = linker.processXpathLinking(augment.getTargetNode(), node); |
| 559 | } |
| 560 | } |
| 561 | |
| 562 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 563 | */ |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * Unit test case for inter file linking for multi level uses. |
| 568 | * |
| 569 | * @throws IOException when fails to do IO operations |
| 570 | */ |
| 571 | @Test |
| 572 | public void processInterFileLinkingInUsesMultiLevel() throws IOException { |
| 573 | |
| 574 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/")); |
| 575 | utilManager.parseYangFileInfoSet(); |
| 576 | utilManager.createYangNodeSet(); |
| 577 | linkerManager.createYangNodeSet(utilManager.getYangNodeSet()); |
| 578 | linkerManager.addRefToYangFilesImportList(utilManager.getYangNodeSet()); |
| 579 | linkerManager.addRefToYangFilesIncludeList(utilManager.getYangNodeSet()); |
| 580 | linkerManager.processInterFileLinking(utilManager.getYangNodeSet()); |
| 581 | |
| 582 | YangNode targetNode = null; |
| 583 | String targetNodeName = null; |
| 584 | |
| 585 | for (YangNode node : utilManager.getYangNodeSet()) { |
| 586 | List<YangAugment> augments = linker.getListOfYangAugment(node); |
| 587 | |
| 588 | for (YangAugment augment : augments) { |
| 589 | targetNodeName = augment.getTargetNode().get(augment.getTargetNode().size() - 1).getNodeIdentifier() |
| 590 | .getName(); |
| 591 | targetNode = linker.processAugmentXpathLinking(augment.getTargetNode(), node); |
| 592 | } |
| 593 | } |
| 594 | |
| 595 | assertThat(true, is(targetNode.getName().equals(targetNodeName))); |
| 596 | } |
| 597 | |
| 598 | } |