1 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
4 import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName;
6 import java.io.IOException;
8 import static java.util.Arrays.asList;
9 import static org.junit.Assert.assertEquals;
10 import static org.junit.Assert.assertTrue;
12 public class StringUtilTest {
14 public void testPrefixAndJoin() {
15 assertEquals(" extends p1.Foo,Bar", StringUtil.prefixAndJoin(asList(
16 new FullyQualifiedName("p1", "Foo"), new FullyQualifiedName("", "Bar")), "extends"));
20 public void testAddAsterixAtEachLineStart() {
21 String input = "foo \nbar";
22 String expectedOutput = "* foo\n* bar\n";
23 assertEquals(expectedOutput, StringUtil.addAsterixAtEachLineStart(input));
27 public void testCopyright() throws IOException {
28 assertTrue(StringUtil.loadCopyright().isPresent());
32 public void testFormatting() {
34 String input = " \tpack;\n" +
40 String expected = "pack;\n" +
46 assertEquals(expected, StringUtil.formatJavaSource(input));
49 String input = "{\n" +
53 String expected = "{\n" +
57 assertEquals(expected, StringUtil.formatJavaSource(input));