Remove yang-test
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / test / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / util / StringUtilTest.java
1 /*
2  * Copyright (c) 2013, 2015 Cisco 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
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
10
11 import static java.util.Arrays.asList;
12 import static org.junit.Assert.assertEquals;
13 import static org.junit.Assert.assertTrue;
14
15 import java.io.IOException;
16 import org.junit.Ignore;
17 import org.junit.Test;
18 import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName;
19
20 public class StringUtilTest {
21     @Test
22     public void testPrefixAndJoin() {
23         assertEquals(" extends p1.Foo,Bar", StringUtil.prefixAndJoin(asList(
24                 new FullyQualifiedName("p1", "Foo"), new FullyQualifiedName("", "Bar")), "extends"));
25     }
26
27     @Test
28     public void testAddAsterixAtEachLineStart() {
29         String input = "foo   \nbar";
30         String expectedOutput = "* foo\n* bar\n";
31         assertEquals(expectedOutput, StringUtil.addAsterixAtEachLineStart(input));
32     }
33
34     @Test
35     @Ignore
36     public void testCopyright() throws IOException {
37         assertTrue(StringUtil.loadCopyright().isPresent());
38     }
39
40     @Test
41     public void testFormatting() {
42         {
43             String input = "  \tpack;\n" +
44                 "class Bar{ \n" +
45                 " method() {\n" +
46                 "  body\n" +
47                 "}\n" +
48                 "  }";
49             String expected = "pack;\n" +
50                 "class Bar{\n" +
51                 "    method() {\n" +
52                 "        body\n" +
53                 "    }\n" +
54                 "}\n";
55             assertEquals(expected, StringUtil.formatJavaSource(input));
56         }
57         {
58             String input = "{\n" +
59                     "bar\n" +
60                     "}\n" +
61                     "\n\nbaz\n\n\n\n";
62             String expected = "{\n" +
63                     "    bar\n" +
64                     "}\n\n" +
65                     "baz\n";
66             assertEquals(expected, StringUtil.formatJavaSource(input));
67         }
68     }
69 }