2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import java.util.Iterator;
15 import org.junit.Test;
16 import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
17 import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
18 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
21 public class Mdsal269Test {
23 public void mdsal269Test() {
24 final var generateTypes = DefaultBindingGenerator.generateFor(
25 YangParserTestUtils.parseYangResource("/mdsal269.yang"));
26 assertEquals(4, generateTypes.size());
28 final GeneratedType mplsLabelType = generateTypes.stream().filter(type -> type.getFullyQualifiedName()
29 .equals("org.opendaylight.yang.gen.v1.mdsal269.rev180130.MplsLabel")).findFirst().get();
31 assertTrue(mplsLabelType instanceof GeneratedTransferObject);
32 final GeneratedTransferObject gto = (GeneratedTransferObject) mplsLabelType;
33 final Iterator<GeneratedProperty> it = gto.getEqualsIdentifiers().iterator();
34 final GeneratedProperty special = it.next();
35 final GeneratedProperty general = it.next();
36 assertFalse(it.hasNext());
38 assertEquals("mplsLabelGeneralUse", general.getName());
39 assertEquals("org.opendaylight.yang.gen.v1.mdsal269.rev180130.MplsLabelGeneralUse",
40 general.getReturnType().getFullyQualifiedName());
42 assertEquals("mplsLabelSpecialPurpose", special.getName());
43 assertEquals("java.lang.Class", special.getReturnType().getFullyQualifiedName());