package com.fishercoder;

import com.fishercoder.common.classes.TreeNode;
import com.fishercoder.solutions._145;
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;

public class _145Test {
  private static _145.Solution1 solution1;
  private static _145.Solution2 solution2;
  private static TreeNode root;
  private static List<Integer> expected;

  @BeforeClass
  public static void setup() {
    solution1 = new _145.Solution1();
    solution2 = new _145.Solution2();
  }

  @Test
  public void test1() {
    root = new TreeNode(1);
    root.left = new TreeNode(2);
    root.right = new TreeNode(3);
    expected = new ArrayList<>(Arrays.asList(2, 3, 1));
    assertEquals(expected, solution1.postorderTraversal(root));
    assertEquals(expected, solution2.postorderTraversal(root));
  }
}

@@ -67,16 +67,112 @@
 eeNode;%0A
+import com.fishercoder.common.utils.CommonUtils;%0Aimport com.fishercoder.common.utils.TreeUtils;%0A
 import c
@@ -403,16 +403,18 @@
 5Test %7B%0A
+  
   privat
@@ -446,24 +446,26 @@
 olution1;%0A  
+ 
+ 
 private stat
@@ -493,16 +493,18 @@
 ution2;%0A
+  
   privat
@@ -527,16 +527,18 @@
 e root;%0A
+  
   privat
@@ -571,16 +571,18 @@
 ected;%0A%0A
+  
   @Befor
@@ -590,16 +590,18 @@
 Class%0A  
+ 
+ 
 public s
@@ -617,24 +617,28 @@
 d setup() %7B%0A
+    
     solution
@@ -663,16 +663,20 @@
 ion1();%0A
+    
     solu
@@ -711,19 +711,23 @@
 ;%0A  
+ 
+ 
 %7D%0A%0A
+  
   @Test%0A
   pu
@@ -722,16 +722,18 @@
   @Test%0A
+  
   public
@@ -744,24 +744,28 @@
 d test1() %7B%0A
+    
     root = n
@@ -767,92 +767,296 @@
 t = 
-new TreeNode(1);%0A    root.left = new TreeNode(2
+TreeUtils.constructBinaryTree(Arrays.asList(1, 2, 3, 4, null, 5, 6, null, 7, null, null, null, null, 8, 9));%0A        TreeUtils.printBinaryTree(root
 );%0A    
+ 
-root.right = new TreeNode(3);%0A
+   CommonUtils.printList(solution1.postorderTraversal(root));%0A        CommonUtils.printList(solution2.postorderTraversal(root));%0A    
     
@@ -1096,17 +1096,35 @@
 .asList(
-2
+8, 9, 7, 4, 2, 5, 6
 , 3, 1))
@@ -1121,24 +1121,28 @@
  6, 3, 1));%0A
+    
     assertEq
@@ -1193,24 +1193,28 @@
 root));%0A    
+ 
+   
 assertEquals
@@ -1261,14 +1261,16 @@
 root));%0A
+  
   %7D%0A%7D%0A

refactor 145