+++ /dev/null
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.net.URI;\r
-import java.util.Date;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.LeafSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.MustDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.builder.TypedefBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class LeafListSchemaNodeBuilderTest {\r
-\r
- private LeafSchemaNodeBuilder tested;\r
-\r
- private final String NAME = "test-leaf";\r
-\r
- private final URI namespace = URI.create("test:leaf.name");\r
- private final Date revision = new Date();\r
- private final String prefix = "x";\r
-\r
- private SchemaPath schemaPath;\r
- private final String description = "description of container";\r
- private final String reference = "reference";\r
-\r
- private QName typedefQName;\r
- private TypeDefinition<?> type;\r
- @Mock private ConstraintDefinition constraint;\r
- @Mock private UsesNodeBuilder usesBuilder;\r
- @Mock private UsesNode uses;\r
- @Mock private MustDefinitionBuilder mustBuilder;\r
- @Mock private MustDefinition must;\r
- @Mock private GroupingBuilder groupingBuilder;\r
- @Mock private GroupingDefinition grouping;\r
-\r
- @Before\r
- public void init() {\r
- MockitoAnnotations.initMocks(this);\r
- when(usesBuilder.build()).thenReturn(uses);\r
- when(mustBuilder.build()).thenReturn(must);\r
- when(groupingBuilder.build()).thenReturn(grouping);\r
-\r
- schemaPath = TestUtils.createSchemaPath(true, namespace, "main", "interface");\r
- typedefQName = new QName(namespace, "test-type");\r
- TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);\r
- type = typeBuilder.build();\r
-\r
- QName qname = new QName(namespace, revision, prefix, NAME);\r
- tested = new LeafSchemaNodeBuilder(qname);\r
- }\r
-\r
- @Test\r
- public void test() {\r
- tested.setType(type);\r
- tested.setPath(schemaPath);\r
- tested.setDescription(description);\r
- tested.setReference(reference);\r
- tested.setStatus(Status.OBSOLOTE);\r
- tested.setConfiguration(false);\r
- tested.setConstraints(constraint);\r
- tested.setMustDefinitionBuilder(mustBuilder);\r
-\r
- LeafSchemaNode result = tested.build();\r
-\r
- assertEquals(type, result.getType());\r
- assertEquals(schemaPath, result.getPath());\r
- assertEquals(description, result.getDescription());\r
- assertEquals(reference, result.getReference());\r
- assertEquals(Status.OBSOLOTE, result.getStatus());\r
- assertFalse(result.isConfiguration());\r
- assertEquals(constraint, result.getConstraints());\r
- assertEquals(must, result.getMustDefinition());\r
- }\r
-\r
-}\r