2 * Copyright (c) 2016 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.mdsal.binding.generator.impl;
10 import static org.junit.Assert.assertEquals;
14 import java.net.URISyntaxException;
15 import java.util.ArrayList;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
20 import org.opendaylight.mdsal.binding.model.api.MethodSignature;
21 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
23 public class IdentityrefTypeTest {
25 private static List<File> testModels = null;
28 public void loadTestResources() throws URISyntaxException {
29 URI folderPath = IdentityrefTypeTest.class.getResource("/identityref.yang").toURI();
30 File folderFile = new File(folderPath);
31 testModels = new ArrayList<>();
33 if (folderFile.isFile()) {
34 testModels.add(folderFile);
36 for (File file : folderFile.listFiles()) {
45 * Test mainly for the method TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition)
46 * provideTypeForIdentityref}.
49 public void testIdentityrefYangBuiltInType() {
50 final List<GeneratedType> genTypes = DefaultBindingGenerator.generateFor(
51 YangParserTestUtils.parseYangFiles(testModels));
52 assertEquals(2, genTypes.size());
54 GeneratedType moduleGenType = genTypes.stream()
55 .filter(type -> type.getName().equals("ModuleIdentityrefData"))
59 List<MethodSignature> methodSignatures = moduleGenType.getMethodDefinitions();
60 assertEquals(2, methodSignatures.size());
62 MethodSignature methodSignature = methodSignatures.get(0);
63 assertEquals("getLf", methodSignature.getName());
64 assertEquals("requireLf", methodSignatures.get(1).getName());
66 assertEquals("org.opendaylight.yang.gen.v1.urn.identityref.module.rev131109.SomeIdentity",
67 methodSignature.getReturnType().getFullyQualifiedName());