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.yangtools.binding.generator.impl;
10 import static org.junit.Assert.assertEquals;
13 import java.net.URISyntaxException;
14 import java.nio.file.Path;
15 import java.util.ArrayList;
16 import java.util.List;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
21 public class IdentityrefTypeTest {
22 private static List<File> testModels;
25 public void loadTestResources() throws URISyntaxException {
26 final var folderFile = Path.of(IdentityrefTypeTest.class.getResource("/identityref.yang").toURI()).toFile();
27 testModels = new ArrayList<>();
29 if (folderFile.isFile()) {
30 testModels.add(folderFile);
32 for (var file : folderFile.listFiles()) {
41 * Test mainly for the method TypeProviderImpl#provideTypeForIdentityref(IdentityrefTypeDefinition)
42 * provideTypeForIdentityref}.
45 public void testIdentityrefYangBuiltInType() {
46 final var genTypes = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYangFiles(testModels));
47 assertEquals(2, genTypes.size());
49 var moduleGenType = genTypes.stream()
50 .filter(type -> type.getName().equals("ModuleIdentityrefData"))
54 var methodSignatures = moduleGenType.getMethodDefinitions();
55 assertEquals(3, methodSignatures.size());
57 assertEquals("implementedInterface", methodSignatures.get(0).getName());
58 var methodSignature = methodSignatures.get(1);
59 assertEquals("getLf", methodSignature.getName());
60 assertEquals("requireLf", methodSignatures.get(2).getName());
62 assertEquals("org.opendaylight.yang.gen.v1.urn.identityref.module.rev131109.SomeIdentity",
63 methodSignature.getReturnType().getFullyQualifiedName());