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
9 package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules;
11 import static junit.framework.TestCase.assertTrue;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertNotNull;
15 import com.google.common.collect.ImmutableList;
16 import java.util.List;
17 import org.junit.Test;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier;
20 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
22 public class ModuleBuilderTest {
25 public void testModuleBuilder() {
26 final ModuleBuilder moduleBuilder = new ModuleBuilder();
27 final Module.Revision revision = new Module.Revision(new RevisionIdentifier("2016-10-11"));
28 final YangIdentifier yangIdentifierOne = new YangIdentifier("YangIdentifier1");
29 final YangIdentifier yangIdentifierTwo = new YangIdentifier("YangIdentifier2");
30 final Uri namespace = new Uri("namespace");
31 final List<YangIdentifier> yangIdentifierList = ImmutableList.of(yangIdentifierOne, yangIdentifierTwo);
32 final ModuleKey moduleKeyOne = new ModuleKey(yangIdentifierOne, revision);
33 final ModuleKey moduleKeyTwo = new ModuleKey(moduleKeyOne);
34 moduleBuilder.setRevision(revision);
35 moduleBuilder.setDeviation(yangIdentifierList);
36 moduleBuilder.setFeature(yangIdentifierList);
37 moduleBuilder.setName(yangIdentifierOne);
38 moduleBuilder.setNamespace(namespace);
39 moduleBuilder.withKey(moduleKeyOne);
40 final Module moduleOne = moduleBuilder.build();
41 final Module moduleTwo = new ModuleBuilder(moduleOne).build();
43 assertNotNull(moduleBuilder);
44 assertNotNull(revision);
45 assertNotNull(yangIdentifierOne);
46 assertNotNull(yangIdentifierTwo);
47 assertNotNull(namespace);
48 assertNotNull(yangIdentifierList);
49 assertNotNull(moduleKeyOne);
50 assertNotNull(moduleKeyOne.hashCode());
51 assertNotNull(moduleKeyOne.toString());
52 assertNotNull(moduleBuilder.toString());
53 assertNotNull(moduleBuilder.hashCode());
55 assertEquals(moduleKeyOne, moduleKeyTwo);
56 assertEquals(revision, moduleKeyOne.getRevision());
57 assertEquals(yangIdentifierOne, moduleKeyOne.getName());
58 assertEquals(revision, moduleBuilder.getRevision());
59 assertEquals(yangIdentifierList, moduleBuilder.getDeviation());
60 assertEquals(yangIdentifierList, moduleBuilder.getFeature());
61 assertEquals(yangIdentifierOne, moduleBuilder.getName());
62 assertEquals(namespace, moduleBuilder.getNamespace());
63 assertEquals(moduleKeyOne, moduleBuilder.key());
64 assertEquals(moduleOne.toString(), moduleTwo.toString());
65 assertEquals(moduleKeyOne.toString(), moduleKeyTwo.toString());
67 assertTrue(moduleOne.equals(moduleTwo));
68 assertTrue(moduleKeyOne.equals(moduleKeyTwo));