2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.yang.model.parser.builder.impl;
10 import static org.junit.Assert.*;
11 import static org.mockito.Mockito.when;
14 import java.util.Date;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.controller.yang.common.QName;
21 import org.opendaylight.controller.yang.model.api.GroupingDefinition;
22 import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
23 import org.opendaylight.controller.yang.model.api.SchemaPath;
24 import org.opendaylight.controller.yang.model.api.Status;
25 import org.opendaylight.controller.yang.model.api.TypeDefinition;
26 import org.opendaylight.controller.yang.model.api.UsesNode;
27 import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
28 import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
30 public class LeafListSchemaNodeBuilderTest {
32 private LeafListSchemaNodeBuilder tested;
34 private final String NAME = "test-leaf";
36 private final URI namespace = URI.create("test:leaf.name");
37 private final Date revision = new Date();
38 private final String prefix = "x";
40 private SchemaPath schemaPath;
41 private final String description = "description of container";
42 private final String reference = "reference";
44 private QName typedefQName;
45 private TypeDefinition<?> type;
48 private UsesNodeBuilder usesBuilder;
50 private UsesNode uses;
52 private GroupingBuilder groupingBuilder;
54 private GroupingDefinition grouping;
58 MockitoAnnotations.initMocks(this);
59 when(usesBuilder.build()).thenReturn(uses);
60 when(groupingBuilder.build()).thenReturn(grouping);
62 schemaPath = TestUtils.createSchemaPath(true, namespace, "main",
64 typedefQName = new QName(namespace, "test-type");
65 TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);
66 type = typeBuilder.build();
68 QName qname = new QName(namespace, revision, prefix, NAME);
69 tested = new LeafListSchemaNodeBuilder(qname);
75 tested.setPath(schemaPath);
76 tested.setDescription(description);
77 tested.setReference(reference);
78 tested.setStatus(Status.OBSOLETE);
79 tested.setConfiguration(false);
81 LeafListSchemaNode result = tested.build();
83 assertEquals(type, result.getType());
84 assertEquals(schemaPath, result.getPath());
85 assertEquals(description, result.getDescription());
86 assertEquals(reference, result.getReference());
87 assertEquals(Status.OBSOLETE, result.getStatus());
88 assertFalse(result.isConfiguration());