Adding more testcases to Misc xgen
[aaf/authz.git] / misc / xgen / src / test / java / org / onap / aaf / misc / xgen / JU_SectionTest.java
diff --git a/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java b/misc/xgen/src/test/java/org/onap/aaf/misc/xgen/JU_SectionTest.java
new file mode 100644 (file)
index 0000000..a45ea15
--- /dev/null
@@ -0,0 +1,64 @@
+/**\r
+ * ============LICENSE_START====================================================\r
+ * org.onap.aaf\r
+ * ===========================================================================\r
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.\r
+ * ===========================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ * \r
+ *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * \r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END====================================================\r
+ *\r
+ */\r
+package org.onap.aaf.misc.xgen;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.onap.aaf.misc.env.APIException;\r
+\r
+public class JU_SectionTest {\r
+\r
+       @Mock\r
+       private Writer writer;\r
+\r
+       @Before\r
+       public void setup() {\r
+               writer = mock(Writer.class);\r
+       }\r
+\r
+       @Test\r
+       @SuppressWarnings({ "rawtypes", "unchecked" })\r
+       public void test() throws APIException, IOException {\r
+               Section section = new Section();\r
+               section.forward = "Forward";\r
+               section.backward = "Backward";\r
+\r
+               section.setIndent(10);\r
+               section.forward(writer);\r
+               section.back(writer);\r
+\r
+               assertEquals(section.use(null, null, null), section);\r
+               assertEquals(section.getIndent(), 10);\r
+               assertEquals(section.toString(), "Forward");\r
+\r
+               verify(writer).write("Forward");\r
+               verify(writer).write("Backward");\r
+       }\r
+\r
+}\r