Committed by
Gerrit Code Review
[ONOS-4636]grouping and uses
Change-Id: Ic410d03a838003ad23b2b0e8874b91503da84153
Showing
10 changed files
with
548 additions
and
321 deletions
utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/TraversalType.java
0 → 100644
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.yangutils.datamodel; | ||
18 | + | ||
19 | +/** | ||
20 | + * Represents data model tree traversal types. | ||
21 | + */ | ||
22 | +public enum TraversalType { | ||
23 | + | ||
24 | + /** | ||
25 | + * Start of traversal at the tree root. | ||
26 | + */ | ||
27 | + ROOT, | ||
28 | + | ||
29 | + /** | ||
30 | + * Child node traversal. | ||
31 | + */ | ||
32 | + CHILD, | ||
33 | + | ||
34 | + /** | ||
35 | + * Sibling node traversal. | ||
36 | + */ | ||
37 | + SIBILING, | ||
38 | + | ||
39 | + /** | ||
40 | + * Parent node traversal. | ||
41 | + */ | ||
42 | + PARENT | ||
43 | +} |
... | @@ -17,6 +17,13 @@ package org.onosproject.yangutils.datamodel; | ... | @@ -17,6 +17,13 @@ package org.onosproject.yangutils.datamodel; |
17 | 17 | ||
18 | import java.io.Serializable; | 18 | import java.io.Serializable; |
19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 19 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
20 | +import org.onosproject.yangutils.datamodel.utils.Parsable; | ||
21 | + | ||
22 | +import static org.onosproject.yangutils.datamodel.TraversalType.CHILD; | ||
23 | +import static org.onosproject.yangutils.datamodel.TraversalType.PARENT; | ||
24 | +import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING; | ||
25 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.cloneLeaves; | ||
26 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef; | ||
20 | 27 | ||
21 | /** | 28 | /** |
22 | * Represents base class of a node in data model tree. | 29 | * Represents base class of a node in data model tree. |
... | @@ -226,4 +233,189 @@ public abstract class YangNode | ... | @@ -226,4 +233,189 @@ public abstract class YangNode |
226 | newChild.setPreviousSibling(curNode); | 233 | newChild.setPreviousSibling(curNode); |
227 | } | 234 | } |
228 | } | 235 | } |
236 | + | ||
237 | + /** | ||
238 | + * Clones the current node contents and create a new node. | ||
239 | + * | ||
240 | + * @return cloned node | ||
241 | + * @throws CloneNotSupportedException clone is not supported by the referred | ||
242 | + * node | ||
243 | + */ | ||
244 | + public YangNode clone() | ||
245 | + throws CloneNotSupportedException { | ||
246 | + YangNode clonedNode = (YangNode) super.clone(); | ||
247 | + if (clonedNode instanceof YangLeavesHolder) { | ||
248 | + try { | ||
249 | + cloneLeaves((YangLeavesHolder) clonedNode); | ||
250 | + } catch (DataModelException e) { | ||
251 | + throw new CloneNotSupportedException(e.getMessage()); | ||
252 | + } | ||
253 | + } | ||
254 | + | ||
255 | + clonedNode.setParent(null); | ||
256 | + clonedNode.setChild(null); | ||
257 | + clonedNode.setNextSibling(null); | ||
258 | + clonedNode.setPreviousSibling(null); | ||
259 | + return clonedNode; | ||
260 | + } | ||
261 | + | ||
262 | + /** | ||
263 | + * Clones the subtree from the specified source node to the mentioned target | ||
264 | + * node. The source and target root node cloning is carried out by the | ||
265 | + * caller. | ||
266 | + * | ||
267 | + * @param srcRootNode source node for sub tree cloning | ||
268 | + * @param dstRootNode destination node where the sub tree needs to be cloned | ||
269 | + * @throws DataModelException data model error | ||
270 | + */ | ||
271 | + public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode) | ||
272 | + throws DataModelException { | ||
273 | + | ||
274 | + YangNode nextNodeToClone = srcRootNode; | ||
275 | + TraversalType curTraversal; | ||
276 | + | ||
277 | + YangNode clonedTreeCurNode = dstRootNode; | ||
278 | + YangNode newNode = null; | ||
279 | + | ||
280 | + nextNodeToClone = nextNodeToClone.getChild(); | ||
281 | + if (nextNodeToClone == null) { | ||
282 | + return; | ||
283 | + } else { | ||
284 | + /** | ||
285 | + * Root level cloning is taken care in the caller. | ||
286 | + */ | ||
287 | + curTraversal = CHILD; | ||
288 | + } | ||
289 | + | ||
290 | + /** | ||
291 | + * Caller ensures the cloning of the root nodes | ||
292 | + */ | ||
293 | + try { | ||
294 | + while (nextNodeToClone != srcRootNode) { | ||
295 | + if (nextNodeToClone == null) { | ||
296 | + throw new DataModelException("Internal error: Cloning failed, source tree null pointer reached"); | ||
297 | + } | ||
298 | + if (curTraversal != PARENT) { | ||
299 | + newNode = nextNodeToClone.clone(); | ||
300 | + detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal); | ||
301 | + } | ||
302 | + | ||
303 | + if (curTraversal == CHILD) { | ||
304 | + | ||
305 | + /** | ||
306 | + * add the new node to the cloned tree. | ||
307 | + */ | ||
308 | + clonedTreeCurNode.addChild(newNode); | ||
309 | + | ||
310 | + /** | ||
311 | + * update the cloned tree's traversal current node as the | ||
312 | + * new node. | ||
313 | + */ | ||
314 | + clonedTreeCurNode = newNode; | ||
315 | + } else if (curTraversal == SIBILING) { | ||
316 | + | ||
317 | + clonedTreeCurNode.addNextSibling(newNode); | ||
318 | + clonedTreeCurNode = newNode; | ||
319 | + } else if (curTraversal == PARENT) { | ||
320 | + if (clonedTreeCurNode instanceof YangLeavesHolder) { | ||
321 | + updateClonedLeavesUnionEnumRef((YangLeavesHolder) clonedTreeCurNode); | ||
322 | + } | ||
323 | + clonedTreeCurNode = clonedTreeCurNode.getParent(); | ||
324 | + } | ||
325 | + | ||
326 | + if (curTraversal != PARENT && nextNodeToClone.getChild() != null) { | ||
327 | + curTraversal = CHILD; | ||
328 | + | ||
329 | + /** | ||
330 | + * update the traversal's current node. | ||
331 | + */ | ||
332 | + nextNodeToClone = nextNodeToClone.getChild(); | ||
333 | + | ||
334 | + } else if (nextNodeToClone.getNextSibling() != null) { | ||
335 | + | ||
336 | + curTraversal = SIBILING; | ||
337 | + | ||
338 | + nextNodeToClone = nextNodeToClone.getNextSibling(); | ||
339 | + } else { | ||
340 | + curTraversal = PARENT; | ||
341 | + nextNodeToClone = nextNodeToClone.getParent(); | ||
342 | + } | ||
343 | + } | ||
344 | + } catch (CloneNotSupportedException e) { | ||
345 | + throw new DataModelException("Failed to clone the tree"); | ||
346 | + } | ||
347 | + | ||
348 | + } | ||
349 | + | ||
350 | + /** | ||
351 | + * Detects collision when the grouping is deep copied to the uses's parent. | ||
352 | + * | ||
353 | + * @param currentNode parent/previous sibling node for the new node | ||
354 | + * @param newNode node which has to be added | ||
355 | + * @param addAs traversal type of the node | ||
356 | + * @throws DataModelException data model error | ||
357 | + */ | ||
358 | + private static void detectCollisionWhileCloning(YangNode currentNode, YangNode newNode, TraversalType addAs) | ||
359 | + throws DataModelException { | ||
360 | + if (!(currentNode instanceof CollisionDetector) | ||
361 | + || !(newNode instanceof Parsable)) { | ||
362 | + throw new DataModelException("Node in data model tree does not support collision detection"); | ||
363 | + } | ||
364 | + | ||
365 | + CollisionDetector collisionDetector = (CollisionDetector) currentNode; | ||
366 | + Parsable parsable = (Parsable) newNode; | ||
367 | + if (addAs == TraversalType.CHILD) { | ||
368 | + collisionDetector.detectCollidingChild(newNode.getName(), parsable.getYangConstructType()); | ||
369 | + } else if (addAs == TraversalType.SIBILING) { | ||
370 | + currentNode = currentNode.getParent(); | ||
371 | + if (!(currentNode instanceof CollisionDetector)) { | ||
372 | + throw new DataModelException("Node in data model tree does not support collision detection"); | ||
373 | + } | ||
374 | + collisionDetector = (CollisionDetector) currentNode; | ||
375 | + collisionDetector.detectCollidingChild(newNode.getName(), parsable.getYangConstructType()); | ||
376 | + } else { | ||
377 | + throw new DataModelException("Errored tree cloning"); | ||
378 | + } | ||
379 | + | ||
380 | + } | ||
381 | + | ||
382 | + /** | ||
383 | + * Adds a new next sibling. | ||
384 | + * | ||
385 | + * @param newSibling new sibling to be added | ||
386 | + * @throws DataModelException data model error | ||
387 | + */ | ||
388 | + private void addNextSibling(YangNode newSibling) | ||
389 | + throws DataModelException { | ||
390 | + | ||
391 | + if (newSibling.getNodeType() == null) { | ||
392 | + throw new DataModelException("Cloned abstract node cannot be inserted into a tree"); | ||
393 | + } | ||
394 | + | ||
395 | + if (newSibling.getParent() == null) { | ||
396 | + /** | ||
397 | + * Since the siblings needs to have a common parent, set the parent | ||
398 | + * as the current node's parent | ||
399 | + */ | ||
400 | + newSibling.setParent(getParent()); | ||
401 | + | ||
402 | + } else { | ||
403 | + throw new DataModelException("Node is already part of a tree, and cannot be added as a sibling"); | ||
404 | + } | ||
405 | + | ||
406 | + if (newSibling.getPreviousSibling() == null) { | ||
407 | + newSibling.setPreviousSibling(this); | ||
408 | + setNextSibling(newSibling); | ||
409 | + } else { | ||
410 | + throw new DataModelException("New sibling to be added is not atomic, it already has a previous sibling"); | ||
411 | + } | ||
412 | + | ||
413 | + if (newSibling.getChild() != null) { | ||
414 | + throw new DataModelException("Sibling to be added is not atomic, it already has a child"); | ||
415 | + } | ||
416 | + | ||
417 | + if (newSibling.getNextSibling() != null) { | ||
418 | + throw new DataModelException("Sibling to be added is not atomic, it already has a next sibling"); | ||
419 | + } | ||
420 | + } | ||
229 | } | 421 | } | ... | ... |
... | @@ -25,6 +25,7 @@ import org.onosproject.yangutils.datamodel.utils.YangConstructType; | ... | @@ -25,6 +25,7 @@ import org.onosproject.yangutils.datamodel.utils.YangConstructType; |
25 | 25 | ||
26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; | 26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | 27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; |
28 | +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef; | ||
28 | 29 | ||
29 | /*- | 30 | /*- |
30 | * Reference RFC 6020. | 31 | * Reference RFC 6020. |
... | @@ -329,42 +330,45 @@ public class YangUses | ... | @@ -329,42 +330,45 @@ public class YangUses |
329 | } | 330 | } |
330 | 331 | ||
331 | YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode; | 332 | YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode; |
332 | - if (referredGrouping.getListOfLeaf() != null | 333 | + if (referredGrouping.getListOfLeaf() != null) { |
333 | - && referredGrouping.getListOfLeaf().size() != 0) { | 334 | + for (YangLeaf leaf : referredGrouping.getListOfLeaf()) { |
334 | - addLeavesOfGrouping( | 335 | + YangLeaf clonedLeaf = null; |
335 | - cloneLeavesList(referredGrouping.getListOfLeaf(), | 336 | + try { |
336 | - usesParentLeavesHolder)); | 337 | + ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getName(), |
337 | - } | 338 | + YangConstructType.LEAF_DATA); |
339 | + clonedLeaf = leaf.clone(); | ||
338 | 340 | ||
339 | - if (referredGrouping.getListOfLeafList() != null | 341 | + } catch (CloneNotSupportedException | DataModelException e) { |
340 | - && referredGrouping.getListOfLeafList().size() != 0) { | 342 | + throw new DataModelException(e.getMessage()); |
341 | - addListOfLeafListOfGrouping( | ||
342 | - cloneListOfLeafList(referredGrouping.getListOfLeafList(), | ||
343 | - usesParentLeavesHolder)); | ||
344 | } | 343 | } |
345 | 344 | ||
346 | - YangNode childInGrouping = referredGrouping.getChild(); | 345 | + clonedLeaf.setContainedIn(usesParentLeavesHolder); |
346 | + usesParentLeavesHolder.addLeaf(clonedLeaf); | ||
347 | + } | ||
348 | + } | ||
349 | + if (referredGrouping.getListOfLeafList() != null) { | ||
350 | + for (YangLeafList leafList : referredGrouping.getListOfLeafList()) { | ||
351 | + YangLeafList clonedLeafList = null; | ||
352 | + try { | ||
353 | + ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getName(), | ||
354 | + YangConstructType.LEAF_LIST_DATA); | ||
355 | + clonedLeafList = leafList.clone(); | ||
347 | 356 | ||
348 | - while (childInGrouping != null) { | 357 | + } catch (CloneNotSupportedException | DataModelException e) { |
349 | - if (childInGrouping instanceof YangEnumeration | 358 | + throw new DataModelException(e.getMessage()); |
350 | - || childInGrouping instanceof YangUnion | 359 | + } |
351 | - || childInGrouping instanceof YangTypeDef) { | ||
352 | 360 | ||
353 | - /* | 361 | + clonedLeafList.setContainedIn(usesParentLeavesHolder); |
354 | - * No need to copy the leaves, union / enum class, as these will | 362 | + usesParentLeavesHolder.addLeafList(clonedLeafList); |
355 | - * be generated in the scope of grouping | 363 | + } |
356 | - */ | ||
357 | - childInGrouping = childInGrouping.getNextSibling(); | ||
358 | - continue; | ||
359 | - } else if (childInGrouping instanceof YangUses) { | ||
360 | - addResolvedUsesInfoOfGrouping((YangUses) childInGrouping, | ||
361 | - usesParentLeavesHolder); | ||
362 | - } else { | ||
363 | - addNodeOfGrouping(childInGrouping); | ||
364 | } | 364 | } |
365 | 365 | ||
366 | - childInGrouping = childInGrouping.getNextSibling(); | 366 | + try { |
367 | + YangNode.cloneSubTree(referredGrouping, usesParentNode); | ||
368 | + } catch (DataModelException e) { | ||
369 | + throw new DataModelException(e.getMessage()); | ||
367 | } | 370 | } |
371 | + updateClonedLeavesUnionEnumRef(usesParentLeavesHolder); | ||
368 | } | 372 | } |
369 | 373 | ||
370 | /** | 374 | /** | ... | ... |
... | @@ -20,6 +20,7 @@ import java.io.FileInputStream; | ... | @@ -20,6 +20,7 @@ import java.io.FileInputStream; |
20 | import java.io.IOException; | 20 | import java.io.IOException; |
21 | import java.io.ObjectInputStream; | 21 | import java.io.ObjectInputStream; |
22 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
23 | +import java.util.LinkedList; | ||
23 | import java.util.List; | 24 | import java.util.List; |
24 | import java.util.Set; | 25 | import java.util.Set; |
25 | 26 | ||
... | @@ -28,6 +29,7 @@ import org.onosproject.yangutils.datamodel.ResolvableType; | ... | @@ -28,6 +29,7 @@ import org.onosproject.yangutils.datamodel.ResolvableType; |
28 | import org.onosproject.yangutils.datamodel.YangIfFeature; | 29 | import org.onosproject.yangutils.datamodel.YangIfFeature; |
29 | import org.onosproject.yangutils.datamodel.YangAugment; | 30 | import org.onosproject.yangutils.datamodel.YangAugment; |
30 | import org.onosproject.yangutils.datamodel.YangBase; | 31 | import org.onosproject.yangutils.datamodel.YangBase; |
32 | +import org.onosproject.yangutils.datamodel.YangEnumeration; | ||
31 | import org.onosproject.yangutils.datamodel.YangIdentityRef; | 33 | import org.onosproject.yangutils.datamodel.YangIdentityRef; |
32 | import org.onosproject.yangutils.datamodel.YangLeaf; | 34 | import org.onosproject.yangutils.datamodel.YangLeaf; |
33 | import org.onosproject.yangutils.datamodel.YangLeafList; | 35 | import org.onosproject.yangutils.datamodel.YangLeafList; |
... | @@ -38,8 +40,10 @@ import org.onosproject.yangutils.datamodel.YangReferenceResolver; | ... | @@ -38,8 +40,10 @@ import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
38 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; | 40 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; |
39 | import org.onosproject.yangutils.datamodel.YangRpc; | 41 | import org.onosproject.yangutils.datamodel.YangRpc; |
40 | import org.onosproject.yangutils.datamodel.YangType; | 42 | import org.onosproject.yangutils.datamodel.YangType; |
43 | +import org.onosproject.yangutils.datamodel.YangUnion; | ||
41 | import org.onosproject.yangutils.datamodel.YangUses; | 44 | import org.onosproject.yangutils.datamodel.YangUses; |
42 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 45 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
46 | +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
43 | 47 | ||
44 | /** | 48 | /** |
45 | * Represents utilities for data model tree. | 49 | * Represents utilities for data model tree. |
... | @@ -307,4 +311,104 @@ public final class DataModelUtils { | ... | @@ -307,4 +311,104 @@ public final class DataModelUtils { |
307 | } | 311 | } |
308 | return nodes; | 312 | return nodes; |
309 | } | 313 | } |
314 | + | ||
315 | + /** | ||
316 | + * Clones the list of leaves and list of leaf list in the leaves holder. | ||
317 | + * | ||
318 | + * @param leavesHolder YANG node potentially containing leaves or leaf lists | ||
319 | + * @throws CloneNotSupportedException clone is not supported | ||
320 | + * @throws DataModelException data model error | ||
321 | + */ | ||
322 | + public static void cloneLeaves(YangLeavesHolder leavesHolder) | ||
323 | + throws CloneNotSupportedException, DataModelException { | ||
324 | + List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf(); | ||
325 | + if (currentListOfLeaves != null) { | ||
326 | + List<YangLeaf> clonedLeavesList = new LinkedList<YangLeaf>(); | ||
327 | + for (YangLeaf leaf : currentListOfLeaves) { | ||
328 | + YangLeaf clonedLeaf = leaf.clone(); | ||
329 | + clonedLeaf.setContainedIn(leavesHolder); | ||
330 | + clonedLeavesList.add(clonedLeaf); | ||
331 | + } | ||
332 | + leavesHolder.setListOfLeaf(clonedLeavesList); | ||
333 | + } | ||
334 | + | ||
335 | + List<YangLeafList> currentListOfLeafList = leavesHolder.getListOfLeafList(); | ||
336 | + if (currentListOfLeafList != null) { | ||
337 | + List<YangLeafList> clonedListOfLeafList = new LinkedList<YangLeafList>(); | ||
338 | + for (YangLeafList leafList : currentListOfLeafList) { | ||
339 | + YangLeafList clonedLeafList = leafList.clone(); | ||
340 | + clonedLeafList.setContainedIn(leavesHolder); | ||
341 | + clonedListOfLeafList.add(clonedLeafList); | ||
342 | + } | ||
343 | + leavesHolder.setListOfLeafList(clonedListOfLeafList); | ||
344 | + } | ||
345 | + } | ||
346 | + | ||
347 | + /** | ||
348 | + * Clones the union or enum leaves. If there is any cloned leaves whose type is union/enum then the corresponding | ||
349 | + * type info needs to be updated to the cloned new type node. | ||
350 | + * | ||
351 | + * @param leavesHolder cloned leaves holder, for whom the leaves reference needs to be updated | ||
352 | + */ | ||
353 | + public static void updateClonedLeavesUnionEnumRef(YangLeavesHolder leavesHolder) throws DataModelException { | ||
354 | + List<YangLeaf> currentListOfLeaves = leavesHolder.getListOfLeaf(); | ||
355 | + if (currentListOfLeaves != null) { | ||
356 | + for (YangLeaf leaf : currentListOfLeaves) { | ||
357 | + if (leaf.getDataType().getDataType() == YangDataTypes.ENUMERATION | ||
358 | + || leaf.getDataType().getDataType() == YangDataTypes.UNION) { | ||
359 | + try { | ||
360 | + updateClonedTypeRef(leaf.getDataType(), leavesHolder); | ||
361 | + } catch (DataModelException e) { | ||
362 | + throw e; | ||
363 | + } | ||
364 | + } | ||
365 | + } | ||
366 | + | ||
367 | + } | ||
368 | + | ||
369 | + List<YangLeafList> currentListOfLeafList = leavesHolder.getListOfLeafList(); | ||
370 | + if (currentListOfLeafList != null) { | ||
371 | + for (YangLeafList leafList : currentListOfLeafList) { | ||
372 | + if (leafList.getDataType().getDataType() == YangDataTypes.ENUMERATION | ||
373 | + || leafList.getDataType().getDataType() == YangDataTypes.UNION) { | ||
374 | + try { | ||
375 | + updateClonedTypeRef(leafList.getDataType(), leavesHolder); | ||
376 | + } catch (DataModelException e) { | ||
377 | + throw e; | ||
378 | + } | ||
379 | + } | ||
380 | + } | ||
381 | + } | ||
382 | + } | ||
383 | + | ||
384 | + /** | ||
385 | + * Updates the types extended info pointer to point to the cloned type node. | ||
386 | + * | ||
387 | + * @param dataType data type, whose extended info needs to be pointed to the cloned type | ||
388 | + * @param leavesHolder the leaves holder having the cloned type | ||
389 | + */ | ||
390 | + private static void updateClonedTypeRef(YangType dataType, YangLeavesHolder leavesHolder) | ||
391 | + throws DataModelException { | ||
392 | + if (!(leavesHolder instanceof YangNode)) { | ||
393 | + throw new DataModelException("Data model error: cloned leaves holder is not a node"); | ||
394 | + } | ||
395 | + YangNode potentialTypeNode = ((YangNode) leavesHolder).getChild(); | ||
396 | + while (potentialTypeNode != null) { | ||
397 | + String dataTypeName = null; | ||
398 | + if (dataType.getDataType() == YangDataTypes.ENUMERATION) { | ||
399 | + YangEnumeration enumNode = (YangEnumeration) dataType.getDataTypeExtendedInfo(); | ||
400 | + dataTypeName = enumNode.getName(); | ||
401 | + } else if (dataType.getDataType() == YangDataTypes.UNION) { | ||
402 | + YangUnion unionNode = (YangUnion) dataType.getDataTypeExtendedInfo(); | ||
403 | + dataTypeName = unionNode.getName(); | ||
404 | + } | ||
405 | + if (potentialTypeNode.getName().contentEquals(dataTypeName)) { | ||
406 | + dataType.setDataTypeExtendedInfo((Object) potentialTypeNode); | ||
407 | + return; | ||
408 | + } | ||
409 | + potentialTypeNode = potentialTypeNode.getNextSibling(); | ||
410 | + } | ||
411 | + | ||
412 | + throw new DataModelException("Data model error: cloned leaves type is not found"); | ||
413 | + } | ||
310 | } | 414 | } | ... | ... |
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.yangutils.translator.exception; | ||
18 | + | ||
19 | +/** | ||
20 | + * Represents custom translator exception for translator's operations. | ||
21 | + */ | ||
22 | +public class InvalidNodeForTranslatorException extends RuntimeException { | ||
23 | + | ||
24 | + private static final long serialVersionUID = 20160311L; | ||
25 | + private String fileName; | ||
26 | + | ||
27 | + /** | ||
28 | + * Create a new exception. | ||
29 | + */ | ||
30 | + public InvalidNodeForTranslatorException() { | ||
31 | + super(); | ||
32 | + } | ||
33 | + | ||
34 | + /** | ||
35 | + * Creates a new exception with given message. | ||
36 | + * | ||
37 | + * @param message the detail of exception in string | ||
38 | + */ | ||
39 | + public InvalidNodeForTranslatorException(String message) { | ||
40 | + super(message); | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Creates a new exception from given message and cause. | ||
45 | + * | ||
46 | + * @param message the detail of exception in string | ||
47 | + * @param cause underlying cause of the error | ||
48 | + */ | ||
49 | + public InvalidNodeForTranslatorException(final String message, final Throwable cause) { | ||
50 | + super(message, cause); | ||
51 | + } | ||
52 | + | ||
53 | + /** | ||
54 | + * Creates a new exception from cause. | ||
55 | + * | ||
56 | + * @param cause underlying cause of the error | ||
57 | + */ | ||
58 | + public InvalidNodeForTranslatorException(final Throwable cause) { | ||
59 | + super(cause); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * Returns generated file name for the exception. | ||
64 | + * | ||
65 | + * @return generated file name for the exception | ||
66 | + */ | ||
67 | + public String getFileName() { | ||
68 | + return this.fileName; | ||
69 | + } | ||
70 | + | ||
71 | + /** | ||
72 | + * Sets file name in translator exception. | ||
73 | + * | ||
74 | + * @param fileName generated file name | ||
75 | + */ | ||
76 | + public void setFileName(String fileName) { | ||
77 | + this.fileName = fileName; | ||
78 | + } | ||
79 | +} |
... | @@ -17,17 +17,16 @@ | ... | @@ -17,17 +17,16 @@ |
17 | package org.onosproject.yangutils.translator.tojava; | 17 | package org.onosproject.yangutils.translator.tojava; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | - | 20 | +import org.onosproject.yangutils.datamodel.TraversalType; |
21 | import org.onosproject.yangutils.datamodel.YangNode; | 21 | import org.onosproject.yangutils.datamodel.YangNode; |
22 | -import org.onosproject.yangutils.datamodel.YangTypeDef; | 22 | +import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; |
23 | -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
24 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 23 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
25 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 24 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
26 | 25 | ||
27 | -import static org.onosproject.yangutils.translator.tojava.TraversalType.CHILD; | 26 | +import static org.onosproject.yangutils.datamodel.TraversalType.CHILD; |
28 | -import static org.onosproject.yangutils.translator.tojava.TraversalType.PARENT; | 27 | +import static org.onosproject.yangutils.datamodel.TraversalType.PARENT; |
29 | -import static org.onosproject.yangutils.translator.tojava.TraversalType.ROOT; | 28 | +import static org.onosproject.yangutils.datamodel.TraversalType.ROOT; |
30 | -import static org.onosproject.yangutils.translator.tojava.TraversalType.SIBILING; | 29 | +import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING; |
31 | 30 | ||
32 | /** | 31 | /** |
33 | * Representation of java code generator based on application schema. | 32 | * Representation of java code generator based on application schema. |
... | @@ -82,10 +81,10 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -82,10 +81,10 @@ public final class JavaCodeGeneratorUtil { |
82 | if (!(codeGenNode instanceof JavaCodeGenerator)) { | 81 | if (!(codeGenNode instanceof JavaCodeGenerator)) { |
83 | throw new TranslatorException("Unsupported node to generate code"); | 82 | throw new TranslatorException("Unsupported node to generate code"); |
84 | } | 83 | } |
85 | - if (codeGenNode instanceof YangTypeDef) { | 84 | + setCurNode(codeGenNode); |
86 | - YangTypeDef typeDef = (YangTypeDef) codeGenNode; | 85 | + try { |
87 | - if (typeDef.getTypeDefBaseType().getDataType() == YangDataTypes.LEAFREF | 86 | + generateCodeEntry(codeGenNode, yangPlugin); |
88 | - || typeDef.getTypeDefBaseType().getDataType() == YangDataTypes.IDENTITYREF) { | 87 | + } catch (InvalidNodeForTranslatorException e) { |
89 | if (codeGenNode.getNextSibling() != null) { | 88 | if (codeGenNode.getNextSibling() != null) { |
90 | curTraversal = SIBILING; | 89 | curTraversal = SIBILING; |
91 | codeGenNode = codeGenNode.getNextSibling(); | 90 | codeGenNode = codeGenNode.getNextSibling(); |
... | @@ -94,11 +93,6 @@ public final class JavaCodeGeneratorUtil { | ... | @@ -94,11 +93,6 @@ public final class JavaCodeGeneratorUtil { |
94 | codeGenNode = codeGenNode.getParent(); | 93 | codeGenNode = codeGenNode.getParent(); |
95 | } | 94 | } |
96 | continue; | 95 | continue; |
97 | - } | ||
98 | - } | ||
99 | - setCurNode(codeGenNode); | ||
100 | - try { | ||
101 | - generateCodeEntry(codeGenNode, yangPlugin); | ||
102 | } catch (Exception e) { | 96 | } catch (Exception e) { |
103 | throw new TranslatorException(e.getMessage()); | 97 | throw new TranslatorException(e.getMessage()); |
104 | } | 98 | } | ... | ... |
... | @@ -15,9 +15,8 @@ | ... | @@ -15,9 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | -import java.io.IOException; | ||
19 | - | ||
20 | import org.onosproject.yangutils.datamodel.YangGrouping; | 18 | import org.onosproject.yangutils.datamodel.YangGrouping; |
19 | +import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; | ||
21 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 20 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
23 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
... | @@ -25,8 +24,6 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ... | @@ -25,8 +24,6 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
25 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
26 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 25 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
27 | 26 | ||
28 | -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; | ||
29 | - | ||
30 | /** | 27 | /** |
31 | * Represents grouping information extended to support java code generation. | 28 | * Represents grouping information extended to support java code generation. |
32 | */ | 29 | */ |
... | @@ -102,11 +99,7 @@ public class YangJavaGrouping | ... | @@ -102,11 +99,7 @@ public class YangJavaGrouping |
102 | @Override | 99 | @Override |
103 | public void generateCodeEntry(YangPluginConfig yangPlugin) | 100 | public void generateCodeEntry(YangPluginConfig yangPlugin) |
104 | throws TranslatorException { | 101 | throws TranslatorException { |
105 | - try { | 102 | + throw new InvalidNodeForTranslatorException(); |
106 | - updatePackageInfo(this, yangPlugin); | ||
107 | - } catch (IOException e) { | ||
108 | - throw new TranslatorException(e.getCause()); | ||
109 | - } | ||
110 | } | 103 | } |
111 | 104 | ||
112 | @Override | 105 | @Override | ... | ... |
... | @@ -15,14 +15,8 @@ | ... | @@ -15,14 +15,8 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.yangutils.translator.tojava.javamodel; | 16 | package org.onosproject.yangutils.translator.tojava.javamodel; |
17 | 17 | ||
18 | -import java.io.IOException; | ||
19 | -import java.util.List; | ||
20 | - | ||
21 | -import org.onosproject.yangutils.datamodel.YangGrouping; | ||
22 | -import org.onosproject.yangutils.datamodel.YangLeaf; | ||
23 | -import org.onosproject.yangutils.datamodel.YangLeafList; | ||
24 | -import org.onosproject.yangutils.datamodel.YangNode; | ||
25 | import org.onosproject.yangutils.datamodel.YangUses; | 18 | import org.onosproject.yangutils.datamodel.YangUses; |
19 | +import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; | ||
26 | import org.onosproject.yangutils.translator.exception.TranslatorException; | 20 | import org.onosproject.yangutils.translator.exception.TranslatorException; |
27 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; | 21 | import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator; |
28 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; | 22 | import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo; |
... | @@ -30,10 +24,6 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; | ... | @@ -30,10 +24,6 @@ import org.onosproject.yangutils.translator.tojava.JavaFileInfo; |
30 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; | 24 | import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles; |
31 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; | 25 | import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; |
32 | 26 | ||
33 | -import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; | ||
34 | -import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.addCurNodeAsAttributeInTargetTempFile; | ||
35 | -import static org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModelUtils.updatePackageInfo; | ||
36 | - | ||
37 | /** | 27 | /** |
38 | * Represents uses information extended to support java code generation. | 28 | * Represents uses information extended to support java code generation. |
39 | */ | 29 | */ |
... | @@ -108,42 +98,7 @@ public class YangJavaUses | ... | @@ -108,42 +98,7 @@ public class YangJavaUses |
108 | @Override | 98 | @Override |
109 | public void generateCodeEntry(YangPluginConfig yangPlugin) | 99 | public void generateCodeEntry(YangPluginConfig yangPlugin) |
110 | throws TranslatorException { | 100 | throws TranslatorException { |
111 | - try { | 101 | + throw new InvalidNodeForTranslatorException(); |
112 | - updatePackageInfo(this, yangPlugin); | ||
113 | - | ||
114 | - if (!(getParentNodeInGenCode(this) instanceof JavaCodeGeneratorInfo)) { | ||
115 | - throw new TranslatorException("invalid container of uses"); | ||
116 | - } | ||
117 | - JavaCodeGeneratorInfo javaCodeGeneratorInfo = (JavaCodeGeneratorInfo) getParentNodeInGenCode(this); | ||
118 | - | ||
119 | - if (javaCodeGeneratorInfo instanceof YangGrouping) { | ||
120 | - /* | ||
121 | - * Do nothing, since it will taken care in the groupings uses. | ||
122 | - */ | ||
123 | - return; | ||
124 | - } | ||
125 | - | ||
126 | - for (List<YangLeaf> leavesList : getUsesResolvedLeavesList()) { | ||
127 | - // add the resolved leaves to the parent as an attribute | ||
128 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() | ||
129 | - .getBeanTempFiles().addLeavesInfoToTempFiles(leavesList, yangPlugin); | ||
130 | - } | ||
131 | - | ||
132 | - for (List<YangLeafList> listOfLeafLists : getUsesResolvedListOfLeafList()) { | ||
133 | - // add the resolved leaf-list to the parent as an attribute | ||
134 | - javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles() | ||
135 | - .getBeanTempFiles().addLeafListInfoToTempFiles(listOfLeafLists, yangPlugin); | ||
136 | - } | ||
137 | - | ||
138 | - for (YangNode usesResolvedNode : getUsesResolvedNodeList()) { | ||
139 | - // add the resolved nodes to the parent as an attribute | ||
140 | - addCurNodeAsAttributeInTargetTempFile(usesResolvedNode, yangPlugin, | ||
141 | - getParentNodeInGenCode(this)); | ||
142 | - } | ||
143 | - | ||
144 | - } catch (IOException e) { | ||
145 | - throw new TranslatorException(e.getCause()); | ||
146 | - } | ||
147 | } | 102 | } |
148 | 103 | ||
149 | @Override | 104 | @Override | ... | ... |
... | @@ -17,14 +17,13 @@ | ... | @@ -17,14 +17,13 @@ |
17 | package org.onosproject.yangutils.plugin.manager; | 17 | package org.onosproject.yangutils.plugin.manager; |
18 | 18 | ||
19 | import java.io.IOException; | 19 | import java.io.IOException; |
20 | -import java.util.List; | ||
21 | import java.util.ListIterator; | 20 | import java.util.ListIterator; |
22 | import org.junit.Rule; | 21 | import org.junit.Rule; |
23 | import org.junit.Test; | 22 | import org.junit.Test; |
24 | import org.junit.rules.ExpectedException; | 23 | import org.junit.rules.ExpectedException; |
25 | import org.onosproject.yangutils.datamodel.YangContainer; | 24 | import org.onosproject.yangutils.datamodel.YangContainer; |
26 | -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
27 | import org.onosproject.yangutils.datamodel.YangGrouping; | 25 | import org.onosproject.yangutils.datamodel.YangGrouping; |
26 | +import org.onosproject.yangutils.datamodel.YangInput; | ||
28 | import org.onosproject.yangutils.datamodel.YangLeaf; | 27 | import org.onosproject.yangutils.datamodel.YangLeaf; |
29 | import org.onosproject.yangutils.datamodel.YangList; | 28 | import org.onosproject.yangutils.datamodel.YangList; |
30 | import org.onosproject.yangutils.datamodel.YangModule; | 29 | import org.onosproject.yangutils.datamodel.YangModule; |
... | @@ -33,6 +32,7 @@ import org.onosproject.yangutils.datamodel.YangNodeType; | ... | @@ -33,6 +32,7 @@ import org.onosproject.yangutils.datamodel.YangNodeType; |
33 | import org.onosproject.yangutils.datamodel.YangTypeDef; | 32 | import org.onosproject.yangutils.datamodel.YangTypeDef; |
34 | import org.onosproject.yangutils.datamodel.YangUses; | 33 | import org.onosproject.yangutils.datamodel.YangUses; |
35 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; | 34 | import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; |
35 | +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
36 | import org.onosproject.yangutils.linker.exceptions.LinkerException; | 36 | import org.onosproject.yangutils.linker.exceptions.LinkerException; |
37 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 37 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
38 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; | 38 | import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; |
... | @@ -70,8 +70,13 @@ public class IntraFileUsesLinkingTest { | ... | @@ -70,8 +70,13 @@ public class IntraFileUsesLinkingTest { |
70 | YangModule yangNode = (YangModule) node; | 70 | YangModule yangNode = (YangModule) node; |
71 | assertThat(yangNode.getName(), is("Test")); | 71 | assertThat(yangNode.getName(), is("Test")); |
72 | 72 | ||
73 | - ListIterator<YangLeaf> leafIterator; | 73 | + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator(); |
74 | - YangLeaf leafInfo; | 74 | + YangLeaf leafInfo = leafIterator.next(); |
75 | + | ||
76 | + // Check whether the information in the leaf is correct under module. | ||
77 | + assertThat(leafInfo.getName(), is("hello")); | ||
78 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
79 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
75 | 80 | ||
76 | // Check whether grouping is the sibling of module's child. | 81 | // Check whether grouping is the sibling of module's child. |
77 | assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true)); | 82 | assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true)); |
... | @@ -89,20 +94,9 @@ public class IntraFileUsesLinkingTest { | ... | @@ -89,20 +94,9 @@ public class IntraFileUsesLinkingTest { |
89 | assertThat((yangNode.getChild() instanceof YangUses), is(true)); | 94 | assertThat((yangNode.getChild() instanceof YangUses), is(true)); |
90 | YangUses uses = (YangUses) yangNode.getChild(); | 95 | YangUses uses = (YangUses) yangNode.getChild(); |
91 | 96 | ||
92 | - // Check whether uses get resolved. | 97 | + // Check whether uses get resolved |
93 | assertThat(uses.getResolvableStatus(), | 98 | assertThat(uses.getResolvableStatus(), |
94 | is(ResolvableStatus.RESOLVED)); | 99 | is(ResolvableStatus.RESOLVED)); |
95 | - | ||
96 | - ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator(); | ||
97 | - List<YangLeaf> leafInfo1 = leafIterator1.next(); | ||
98 | - ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); | ||
99 | - YangLeaf leafInfo2 = leafIterator2.next(); | ||
100 | - | ||
101 | - // Check whether the information in the leaf is correct under module. | ||
102 | - assertThat(leafInfo2.getName(), is("hello")); | ||
103 | - assertThat(leafInfo2.getDataType().getDataTypeName(), is("string")); | ||
104 | - assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
105 | - | ||
106 | } | 100 | } |
107 | 101 | ||
108 | /** | 102 | /** |
... | @@ -129,6 +123,27 @@ public class IntraFileUsesLinkingTest { | ... | @@ -129,6 +123,27 @@ public class IntraFileUsesLinkingTest { |
129 | ListIterator<YangLeaf> leafIterator; | 123 | ListIterator<YangLeaf> leafIterator; |
130 | YangLeaf leafInfo; | 124 | YangLeaf leafInfo; |
131 | 125 | ||
126 | + ListIterator<YangLeaf> leafIterator1 = yangNode.getListOfLeaf().listIterator(); | ||
127 | + YangLeaf leafInfo1 = leafIterator1.next(); | ||
128 | + | ||
129 | + // Check whether the information in the leaf is correct under module. | ||
130 | + assertThat(leafInfo1.getName(), is("treat")); | ||
131 | + assertThat(leafInfo1.getDataType().getDataTypeName(), is("string")); | ||
132 | + assertThat(leafInfo1.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
133 | + | ||
134 | + YangContainer container = (YangContainer) yangNode.getChild().getNextSibling().getNextSibling(); | ||
135 | + | ||
136 | + // Check whether the container name is set correctly which is under module. | ||
137 | + assertThat(container.getName(), is("test")); | ||
138 | + | ||
139 | + leafIterator = container.getListOfLeaf().listIterator(); | ||
140 | + leafInfo = leafIterator.next(); | ||
141 | + | ||
142 | + // Check whether the information in the leaf is correct under container which is under module. | ||
143 | + assertThat(leafInfo.getName(), is("leaf2")); | ||
144 | + assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
145 | + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
146 | + | ||
132 | // Check whether grouping is the sibling of module's child. | 147 | // Check whether grouping is the sibling of module's child. |
133 | assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true)); | 148 | assertThat((yangNode.getChild().getNextSibling() instanceof YangGrouping), is(true)); |
134 | 149 | ||
... | @@ -143,7 +158,7 @@ public class IntraFileUsesLinkingTest { | ... | @@ -143,7 +158,7 @@ public class IntraFileUsesLinkingTest { |
143 | 158 | ||
144 | // Check whether container is the child of grouping. | 159 | // Check whether container is the child of grouping. |
145 | assertThat((grouping.getChild() instanceof YangContainer), is(true)); | 160 | assertThat((grouping.getChild() instanceof YangContainer), is(true)); |
146 | - YangContainer container = (YangContainer) grouping.getChild(); | 161 | + container = (YangContainer) grouping.getChild(); |
147 | 162 | ||
148 | // Check whether the container name is set correctly which is under grouping. | 163 | // Check whether the container name is set correctly which is under grouping. |
149 | assertThat(container.getName(), is("test")); | 164 | assertThat(container.getName(), is("test")); |
... | @@ -164,32 +179,6 @@ public class IntraFileUsesLinkingTest { | ... | @@ -164,32 +179,6 @@ public class IntraFileUsesLinkingTest { |
164 | assertThat(uses.getResolvableStatus(), | 179 | assertThat(uses.getResolvableStatus(), |
165 | is(ResolvableStatus.RESOLVED)); | 180 | is(ResolvableStatus.RESOLVED)); |
166 | 181 | ||
167 | - ListIterator<List<YangLeaf>> leafIterator1 = uses.getUsesResolvedLeavesList().listIterator(); | ||
168 | - List<YangLeaf> leafInfo1 = leafIterator1.next(); | ||
169 | - ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); | ||
170 | - YangLeaf leafInfo2 = leafIterator2.next(); | ||
171 | - | ||
172 | - // Check whether the information in the leaf is correct under module. | ||
173 | - assertThat(leafInfo2.getName(), is("treat")); | ||
174 | - assertThat(leafInfo2.getDataType().getDataTypeName(), is("string")); | ||
175 | - assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
176 | - | ||
177 | - ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator(); | ||
178 | - YangNode usesChild = usesChildren.next(); | ||
179 | - // Check whether container is the child of module. | ||
180 | - assertThat((usesChild instanceof YangContainer), is(true)); | ||
181 | - container = (YangContainer) usesChild; | ||
182 | - | ||
183 | - // Check whether the container name is set correctly which is under module. | ||
184 | - assertThat(container.getName(), is("test")); | ||
185 | - | ||
186 | - leafIterator = container.getListOfLeaf().listIterator(); | ||
187 | - leafInfo = leafIterator.next(); | ||
188 | - | ||
189 | - // Check whether the information in the leaf is correct under container which is under module. | ||
190 | - assertThat(leafInfo.getName(), is("leaf2")); | ||
191 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
192 | - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
193 | } | 182 | } |
194 | 183 | ||
195 | /** | 184 | /** |
... | @@ -245,18 +234,12 @@ public class IntraFileUsesLinkingTest { | ... | @@ -245,18 +234,12 @@ public class IntraFileUsesLinkingTest { |
245 | YangUses uses = (YangUses) yangNode.getChild().getChild().getNextSibling().getChild(); | 234 | YangUses uses = (YangUses) yangNode.getChild().getChild().getNextSibling().getChild(); |
246 | 235 | ||
247 | // Check whether uses get resolved. | 236 | // Check whether uses get resolved. |
248 | - assertThat(uses.getResolvableStatus(), | 237 | + assertThat(uses.getResolvableStatus(), is(ResolvableStatus.RESOLVED)); |
249 | - is(ResolvableStatus.RESOLVED)); | ||
250 | - | ||
251 | - ListIterator<YangNode> usesChildren = uses.getUsesResolvedNodeList().listIterator(); | ||
252 | - YangNode usesChild = usesChildren.next(); | ||
253 | - | ||
254 | - // Check whether list is the sibling of uses which has been deep copied from grouping. | ||
255 | - assertThat((usesChild instanceof YangList), is(true)); | ||
256 | 238 | ||
257 | - YangList yangList = (YangList) usesChild; | 239 | + YangInput inputNode = ((YangInput) yangNode.getChild().getChild().getNextSibling()); |
240 | + assertThat((inputNode.getChild() instanceof YangUses), is(true)); | ||
258 | 241 | ||
259 | - // Check whether the list name is set correctly. | 242 | + YangList yangList = ((YangList) inputNode.getChild().getNextSibling()); |
260 | assertThat(yangList.getName(), is("valid")); | 243 | assertThat(yangList.getName(), is("valid")); |
261 | 244 | ||
262 | leafIterator = yangList.getListOfLeaf().listIterator(); | 245 | leafIterator = yangList.getListOfLeaf().listIterator(); |
... | @@ -268,36 +251,6 @@ public class IntraFileUsesLinkingTest { | ... | @@ -268,36 +251,6 @@ public class IntraFileUsesLinkingTest { |
268 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 251 | assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); |
269 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 252 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
270 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 253 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); |
271 | - | ||
272 | - // Check whether uses is output's child. | ||
273 | - assertThat((yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild() instanceof YangUses), | ||
274 | - is(true)); | ||
275 | - YangUses usesInOuput = (YangUses) yangNode.getChild().getChild().getNextSibling().getNextSibling().getChild(); | ||
276 | - | ||
277 | - // Check whether uses get resolved. | ||
278 | - assertThat(usesInOuput.getResolvableStatus(), | ||
279 | - is(ResolvableStatus.RESOLVED)); | ||
280 | - | ||
281 | - ListIterator<YangNode> usesInOuputChildren = usesInOuput.getUsesResolvedNodeList().listIterator(); | ||
282 | - YangNode usesInOuputChild = usesInOuputChildren.next(); | ||
283 | - | ||
284 | - // Check whether list is the sibling of uses which has been deep copied from grouping. | ||
285 | - assertThat((usesInOuputChild instanceof YangList), is(true)); | ||
286 | - | ||
287 | - YangList yangListInOutput = (YangList) usesInOuputChild; | ||
288 | - | ||
289 | - // Check whether the list name is set correctly. | ||
290 | - assertThat(yangListInOutput.getName(), is("valid")); | ||
291 | - | ||
292 | - leafIterator = yangListInOutput.getListOfLeaf().listIterator(); | ||
293 | - leafInfo = leafIterator.next(); | ||
294 | - | ||
295 | - // Check whether the information in the leaf is correct under list which is deep copied. | ||
296 | - assertThat(leafInfo.getName(), is("invalid-interval")); | ||
297 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | ||
298 | - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | ||
299 | - assertThat(leafInfo.getUnits(), is("\"seconds\"")); | ||
300 | - assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | ||
301 | } | 254 | } |
302 | 255 | ||
303 | /** | 256 | /** |
... | @@ -350,18 +303,16 @@ public class IntraFileUsesLinkingTest { | ... | @@ -350,18 +303,16 @@ public class IntraFileUsesLinkingTest { |
350 | YangUses firstUses = (YangUses) grouping.getChild(); | 303 | YangUses firstUses = (YangUses) grouping.getChild(); |
351 | 304 | ||
352 | // Check whether uses get resolved. | 305 | // Check whether uses get resolved. |
353 | - assertThat(firstUses.getResolvableStatus(), | 306 | + assertThat(firstUses.getResolvableStatus(), is(ResolvableStatus.RESOLVED)); |
354 | - is(ResolvableStatus.RESOLVED)); | ||
355 | 307 | ||
356 | - ListIterator<YangNode> firstUsesChildren = firstUses.getUsesResolvedNodeList().listIterator(); | 308 | + // Validate first uses child is cloned properly |
357 | - YangNode firstUsesChild = firstUsesChildren.next(); | 309 | + assertThat((firstUses.getNextSibling().getNextSibling() |
358 | - | 310 | + .getNextSibling().getNextSibling() instanceof YangList), is(true)); |
359 | - // Check whether list is the sibling of uses. | 311 | + YangList firstUsesChild = ((YangList) firstUses.getNextSibling().getNextSibling().getNextSibling() |
360 | - assertThat((firstUsesChild instanceof YangList), is(true)); | 312 | + .getNextSibling()); |
361 | - YangList yangList = (YangList) firstUsesChild; | 313 | + assertThat(firstUsesChild.getName(), is("valid")); |
362 | - assertThat(yangList.getName(), is("valid")); | ||
363 | 314 | ||
364 | - leafIterator = yangList.getListOfLeaf().listIterator(); | 315 | + leafIterator = firstUsesChild.getListOfLeaf().listIterator(); |
365 | leafInfo = leafIterator.next(); | 316 | leafInfo = leafIterator.next(); |
366 | 317 | ||
367 | // Check whether the information in the leaf is correct under list which has been deep copied from grouping. | 318 | // Check whether the information in the leaf is correct under list which has been deep copied from grouping. |
... | @@ -371,134 +322,45 @@ public class IntraFileUsesLinkingTest { | ... | @@ -371,134 +322,45 @@ public class IntraFileUsesLinkingTest { |
371 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 322 | assertThat(leafInfo.getUnits(), is("\"seconds\"")); |
372 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 323 | assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); |
373 | 324 | ||
374 | - // Check whether container is the sibling of uses. | 325 | + //validate uses second |
375 | assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true)); | 326 | assertThat((firstUses.getNextSibling() instanceof YangContainer), is(true)); |
376 | - YangContainer yangContainer = (YangContainer) firstUses.getNextSibling(); | 327 | + YangContainer container = (YangContainer) firstUses.getNextSibling(); |
377 | - | 328 | + assertThat(container.getName(), is("design")); |
378 | - // Check whether the container name is set correctly. | 329 | + |
379 | - assertThat(yangContainer.getName(), is("design")); | 330 | + assertThat((container.getChild() instanceof YangUses), is(true)); |
380 | - | 331 | + assertThat((container.getListOfLeaf().iterator().next().getName()), is("ink")); |
381 | - // Check whether uses is design-container's child. | 332 | + |
382 | - assertThat((yangContainer.getChild() instanceof YangUses), is(true)); | 333 | + //validate uses third |
383 | - YangUses secondUses = (YangUses) yangContainer.getChild(); | 334 | + assertThat((container.getChild().getNextSibling() instanceof YangContainer), is(true)); |
384 | - | 335 | + YangContainer container2 = ((YangContainer) container.getChild().getNextSibling()); |
385 | - // Check whether uses get resolved. | 336 | + assertThat(container2.getName(), is("correct")); |
386 | - assertThat(secondUses.getResolvableStatus(), | 337 | + assertThat((container2.getChild() instanceof YangUses), is(true)); |
387 | - is(ResolvableStatus.RESOLVED)); | 338 | + assertThat((container2.getChild().getNextSibling() instanceof YangContainer), is(true)); |
388 | - | 339 | + YangContainer thirdUsesChild = ((YangContainer) container2.getChild().getNextSibling()); |
389 | - ListIterator<List<YangLeaf>> leafIterator1 = secondUses.getUsesResolvedLeavesList().listIterator(); | 340 | + assertThat(thirdUsesChild.getListOfLeaf().iterator().next().getName(), is("zip-code")); |
390 | - List<YangLeaf> leafInfo1 = leafIterator1.next(); | 341 | + |
391 | - ListIterator<YangLeaf> leafIterator2 = leafInfo1.listIterator(); | 342 | + //validate fourth uses |
392 | - YangLeaf leafInfo2 = leafIterator2.next(); | 343 | + assertThat((firstUses.getNextSibling().getNextSibling() instanceof YangUses), is(true)); |
393 | - | 344 | + YangUses fourthUses = ((YangUses) firstUses.getNextSibling().getNextSibling()); |
394 | - // Check whether the information in the leaf is correct under design-container. | 345 | + assertThat((fourthUses.getNextSibling().getNextSibling().getNextSibling() instanceof YangTypeDef), |
395 | - assertThat(leafInfo2.getName(), is("ink")); | 346 | + is(true)); |
396 | - assertThat(leafInfo2.getDataType().getDataTypeName(), is("int32")); | 347 | + assertThat(fourthUses.getNextSibling().getNextSibling().getNextSibling().getName(), is("my-type")); |
397 | - assertThat(leafInfo2.getDataType().getDataType(), is(YangDataTypes.INT32)); | ||
398 | - | ||
399 | - // Check whether container is the sibling of uses. | ||
400 | - assertThat((secondUses.getNextSibling() instanceof YangContainer), is(true)); | ||
401 | - YangContainer yangContainer2 = (YangContainer) secondUses.getNextSibling(); | ||
402 | - assertThat(yangContainer2.getName(), is("correct")); | ||
403 | - | ||
404 | - leafIterator = yangContainer2.getListOfLeaf().listIterator(); | ||
405 | - leafInfo = leafIterator.next(); | ||
406 | - | ||
407 | - // Check whether the information in the leaf is correct under correct-container. | ||
408 | - assertThat(leafInfo.getName(), is("newone")); | ||
409 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
410 | - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
411 | - | ||
412 | - // Check whether uses is correct container's child. | ||
413 | - assertThat((yangContainer2.getChild() instanceof YangUses), is(true)); | ||
414 | - YangUses thirdUses = (YangUses) yangContainer2.getChild(); | ||
415 | - | ||
416 | - // Check whether uses get resolved. | ||
417 | - assertThat(thirdUses.getResolvableStatus(), | ||
418 | - is(ResolvableStatus.RESOLVED)); | ||
419 | - | ||
420 | - ListIterator<YangNode> thirdUsesChildren = thirdUses.getUsesResolvedNodeList().listIterator(); | ||
421 | - YangNode thirdUsesChild = thirdUsesChildren.next(); | ||
422 | - | ||
423 | - // Check whether container is the child of uses. | ||
424 | - assertThat((thirdUsesChild instanceof YangContainer), is(true)); | ||
425 | - | ||
426 | - YangContainer yangContainer3 = (YangContainer) thirdUsesChild; | ||
427 | - assertThat(yangContainer3.getName(), is("value")); | ||
428 | - | ||
429 | - leafIterator = yangContainer3.getListOfLeaf().listIterator(); | ||
430 | - leafInfo = leafIterator.next(); | ||
431 | - | ||
432 | - // Check whether the information in the leaf is correct under container | ||
433 | - // which has been deep copied from grouping. | ||
434 | - assertThat(leafInfo.getName(), is("zip-code")); | ||
435 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("string")); | ||
436 | - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
437 | - | ||
438 | - | ||
439 | - // Check whether uses is the sibling of container-design. | ||
440 | - assertThat((yangContainer.getNextSibling() instanceof YangUses), is(true)); | ||
441 | - YangUses fourthUses = (YangUses) yangContainer.getNextSibling(); | ||
442 | - assertThat(fourthUses.getName(), is("fourth")); | ||
443 | - // Check whether uses get resolved. | ||
444 | - assertThat(fourthUses.getResolvableStatus(), | ||
445 | - is(ResolvableStatus.RESOLVED)); | ||
446 | - | ||
447 | - ListIterator<List<YangLeaf>> fourthUsesChildren = fourthUses.getUsesResolvedLeavesList().listIterator(); | ||
448 | - List<YangLeaf> fourthUsesChild = fourthUsesChildren.next(); | ||
449 | - ListIterator<YangLeaf> fourthUsesChildren1 = fourthUsesChild.listIterator(); | ||
450 | - YangLeaf fourthUsesChild1 = fourthUsesChildren1.next(); | ||
451 | - | ||
452 | - // Check whether the information in the leaf is correct under correct-container. | ||
453 | - assertThat(fourthUsesChild1.getName(), is("correct")); | ||
454 | - assertThat(fourthUsesChild1.getDataType().getDataTypeName(), is("my-type")); | ||
455 | - assertThat(fourthUsesChild1.getDataType().getDataType(), is(YangDataTypes.DERIVED)); | ||
456 | - | ||
457 | - // Check whether uses is the sibling of previous uses. | ||
458 | - assertThat((fourthUses.getNextSibling() instanceof YangUses), is(true)); | ||
459 | - YangUses fifthUses = (YangUses) fourthUses.getNextSibling(); | ||
460 | - assertThat(fifthUses.getName(), is("fifth")); | ||
461 | - | ||
462 | - // Check whether uses get resolved. | ||
463 | - assertThat(fifthUses.getResolvableStatus(), | ||
464 | - is(ResolvableStatus.RESOLVED)); | ||
465 | - | ||
466 | - ListIterator<List<YangLeaf>> fifthUsesChildren = fifthUses.getUsesResolvedLeavesList().listIterator(); | ||
467 | - List<YangLeaf> fifthUsesChild = fifthUsesChildren.next(); | ||
468 | - ListIterator<YangLeaf> fifthUsesChildren1 = fifthUsesChild.listIterator(); | ||
469 | - YangLeaf fifthUsesChild1 = fifthUsesChildren1.next(); | ||
470 | - | ||
471 | - //Check whether the information in the leaf is correct under correct-container. | ||
472 | - assertThat(fifthUsesChild1.getName(), is("abc")); | ||
473 | - assertThat(fifthUsesChild1.getDataType().getDataTypeName(), is("string")); | ||
474 | - assertThat(fifthUsesChild1.getDataType().getDataType(), is(YangDataTypes.STRING)); | ||
475 | - | ||
476 | - //Check whether uses is endpoint-grouping's sibling. | ||
477 | - assertThat((grouping.getNextSibling() instanceof YangUses), is(true)); | ||
478 | - YangUses endpointUses = (YangUses) grouping.getNextSibling(); | ||
479 | - | ||
480 | - // Check whether uses get resolved. | ||
481 | - assertThat(endpointUses.getResolvableStatus(), | ||
482 | - is(ResolvableStatus.RESOLVED)); | ||
483 | - assertThat(endpointUses.getName(), is("endpoint")); | ||
484 | - | ||
485 | - ListIterator<YangNode> endpointUsesUsesChildren = endpointUses.getUsesResolvedNodeList().listIterator(); | ||
486 | - YangNode endpointUsesUsesChild = endpointUsesUsesChildren.next(); | ||
487 | - | ||
488 | - // Check whether list is the sibling of uses. | ||
489 | - assertThat((endpointUsesUsesChild instanceof YangList), is(true)); | ||
490 | - YangList yangList1 = (YangList) firstUsesChild; | ||
491 | - assertThat(yangList1.getName(), is("valid")); | ||
492 | 348 | ||
493 | - leafIterator = yangList1.getListOfLeaf().listIterator(); | 349 | + //validate fifth uses |
494 | - leafInfo = leafIterator.next(); | 350 | + assertThat((firstUses.getNextSibling().getNextSibling().getNextSibling() instanceof YangUses), |
351 | + is(true)); | ||
495 | 352 | ||
496 | - // Check whether the information in the leaf is correct under list which has been deep copied from grouping. | 353 | + //validate end point uses |
497 | - assertThat(leafInfo.getName(), is("invalid-interval")); | 354 | + assertThat(grouping.getNextSibling() instanceof YangUses, is(true)); |
498 | - assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16")); | 355 | + assertThat(grouping.getNextSibling().getNextSibling().getNextSibling().getNextSibling() |
499 | - assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16)); | 356 | + .getNextSibling().getNextSibling().getNextSibling().getNextSibling() instanceof YangContainer, |
500 | - assertThat(leafInfo.getUnits(), is("\"seconds\"")); | 357 | + is(true)); |
501 | - assertThat(leafInfo.getReference(), is("\"RFC 6020\"")); | 358 | + container = (YangContainer) grouping.getNextSibling().getNextSibling().getNextSibling().getNextSibling() |
359 | + .getNextSibling().getNextSibling().getNextSibling().getNextSibling(); | ||
360 | + assertThat(container.getName(), is("design")); | ||
361 | + container2 = (YangContainer) container.getChild().getNextSibling(); | ||
362 | + assertThat(container2.getName(), is("correct")); | ||
363 | + assertThat(container2.getChild().getNextSibling().getName(), is("value")); | ||
502 | } | 364 | } |
503 | 365 | ||
504 | /** | 366 | /** | ... | ... |
... | @@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangAugment; | ... | @@ -26,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangAugment; |
26 | import org.onosproject.yangutils.datamodel.YangNode; | 26 | import org.onosproject.yangutils.datamodel.YangNode; |
27 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; | 27 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
28 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; | 28 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; |
29 | +import org.onosproject.yangutils.linker.exceptions.LinkerException; | ||
29 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; | 30 | import org.onosproject.yangutils.linker.impl.YangLinkerManager; |
30 | import org.onosproject.yangutils.linker.impl.YangXpathLinker; | 31 | import org.onosproject.yangutils.linker.impl.YangXpathLinker; |
31 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; | 32 | import org.onosproject.yangutils.utils.io.impl.YangFileScanner; |
... | @@ -229,7 +230,7 @@ public class YangXpathLinkerTest { | ... | @@ -229,7 +230,7 @@ public class YangXpathLinkerTest { |
229 | * | 230 | * |
230 | * @throws IOException when fails to do IO operations | 231 | * @throws IOException when fails to do IO operations |
231 | */ | 232 | */ |
232 | - @Test | 233 | + @Test(expected = LinkerException.class) |
233 | public void processIntraFileLinkingInUsesSingleLevel() throws IOException { | 234 | public void processIntraFileLinkingInUsesSingleLevel() throws IOException { |
234 | 235 | ||
235 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/")); | 236 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraSingleUses/")); |
... | @@ -259,7 +260,7 @@ public class YangXpathLinkerTest { | ... | @@ -259,7 +260,7 @@ public class YangXpathLinkerTest { |
259 | * | 260 | * |
260 | * @throws IOException when fails to do IO operations | 261 | * @throws IOException when fails to do IO operations |
261 | */ | 262 | */ |
262 | - @Test | 263 | + @Test(expected = LinkerException.class) |
263 | public void processIntraFileLinkingInUsesMultiLevel() throws IOException { | 264 | public void processIntraFileLinkingInUsesMultiLevel() throws IOException { |
264 | 265 | ||
265 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/")); | 266 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTRA_FILE_PATH + "IntraMultiUses/")); |
... | @@ -568,7 +569,7 @@ public class YangXpathLinkerTest { | ... | @@ -568,7 +569,7 @@ public class YangXpathLinkerTest { |
568 | * | 569 | * |
569 | * @throws IOException when fails to do IO operations | 570 | * @throws IOException when fails to do IO operations |
570 | */ | 571 | */ |
571 | - @Test | 572 | + @Test(expected = LinkerException.class) |
572 | public void processInterFileLinkingInUsesMultiLevel() throws IOException { | 573 | public void processInterFileLinkingInUsesMultiLevel() throws IOException { |
573 | 574 | ||
574 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/")); | 575 | utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(INTER_FILE_PATH + "InterMultiUses/")); | ... | ... |
-
Please register or login to post a comment