Fixed some major sonar issues in yang-validation-tool
[yangtools.git] / model / ietf / ietf-restconf / src / test / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / restconf / rev131019 / restconf / restconf / modules / RevisionBuilderTest.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.RevisionIdentifier;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.restconf.rev131019.restconf.restconf.modules.Module.Revision;
16
17 public class RevisionBuilderTest {
18     @Test
19     public void testEmptyString() {
20         Revision revision = RevisionBuilder.getDefaultInstance("");
21         validate(revision, "", null);
22     }
23
24     @Test
25     public void testValidDataString() {
26         String dateString = "2014-04-23";
27         Revision revision = RevisionBuilder.getDefaultInstance(dateString);
28         validate(revision, null, new RevisionIdentifier(dateString));
29     }
30
31     @Test(expected = IllegalArgumentException.class)
32     public void testNullString() {
33         RevisionBuilder.getDefaultInstance(null);
34     }
35
36     @Test(expected = IllegalArgumentException.class)
37     public void testBadFormatString() {
38         RevisionBuilder.getDefaultInstance("badFormat");
39     }
40
41     private void validate(final Revision revisionUnderTest, final String expectedRevisionString,
42             final RevisionIdentifier expectedRevisionIdentifier) {
43         assertNotNull(revisionUnderTest);
44         assertEquals(expectedRevisionString, revisionUnderTest.getString());
45         assertEquals(expectedRevisionIdentifier, revisionUnderTest.getRevisionIdentifier());
46     }
47 }