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.LeafSchemaNode;
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 LeafSchemaNodeBuilderTest {
32 private LeafSchemaNodeBuilder 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;
47 private UsesNodeBuilder usesBuilder;
49 private UsesNode uses;
51 private GroupingBuilder groupingBuilder;
53 private GroupingDefinition grouping;
57 MockitoAnnotations.initMocks(this);
58 when(usesBuilder.build()).thenReturn(uses);
59 when(groupingBuilder.build()).thenReturn(grouping);
61 schemaPath = TestUtils.createSchemaPath(true, namespace, "main",
63 typedefQName = new QName(namespace, "test-type");
64 TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);
65 type = typeBuilder.build();
67 QName qname = new QName(namespace, revision, prefix, NAME);
68 tested = new LeafSchemaNodeBuilder(qname);
74 tested.setPath(schemaPath);
75 tested.setDescription(description);
76 tested.setReference(reference);
77 tested.setStatus(Status.OBSOLETE);
78 tested.setConfiguration(false);
80 LeafSchemaNode result = tested.build();
82 assertEquals(type, result.getType());
83 assertEquals(schemaPath, result.getPath());
84 assertEquals(description, result.getDescription());
85 assertEquals(reference, result.getReference());
86 assertEquals(Status.OBSOLETE, result.getStatus());
87 assertFalse(result.isConfiguration());