2 * Copyright (c) 2014 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.sal.binding.yang.types;
10 import static org.junit.Assert.assertNotNull;
12 import com.google.common.base.Optional;
13 import java.util.HashSet;
14 import java.util.List;
16 import org.junit.Rule;
17 import org.junit.Test;
18 import org.junit.rules.ExpectedException;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
22 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
23 import org.opendaylight.yangtools.yang.model.util.StringType;
25 public class UnionDependencySortTest {
28 public ExpectedException expException = ExpectedException.none();
31 public void testSortMethod() {
33 final UnionDependencySort unionDependencySort = new UnionDependencySort();
34 final Set<TypeDefinition<?>> typeDefs = new HashSet<>();
36 final StringType stringType = StringType.getInstance();
37 final ExtendedType extendedType = ExtendedType.builder(QName.create("ExtendedType1"), stringType, Optional.<String> absent(), Optional.<String> absent(), SchemaPath.create(false, QName.create("Cont1"), QName.create("List1"))).build();
39 typeDefs.add(stringType);
40 typeDefs.add(extendedType);
42 final List<ExtendedType> sortedExtendedTypes = unionDependencySort.sort(typeDefs);
43 assertNotNull(sortedExtendedTypes);
45 expException.expect(IllegalArgumentException.class);
46 expException.expectMessage("Set of Type Definitions cannot be NULL!");
47 unionDependencySort.sort(null);