MortarScopeDevHelper { public static String scopeHierarchyToString(MortarScope mortarScope) { StringBuilder result = new StringBuilder("Mortar Hierarchy:\n"); MortarScope rootScope = getRootScope(mortarScope); Node rootNode = new MortarScopeNode(rootScope); nodeHierarchyToString(result, 0, 0, rootNode); return result.toString(); } private  MortarScopeDevHelper(); static String scopeHierarchyToString(MortarScope mortarScope);  }
@Test public void nestedScopeHierarchyToString() { MortarScope root = MortarScope.buildRootScope().build("Root"); root.buildChild().build("Cadet"); MortarScope colonel = root.buildChild().build("Colonel"); colonel.buildChild().build("ElderColonel"); colonel.buildChild().build("ZeElderColonel"); MortarScope elder = root.buildChild().build("Elder"); elder.buildChild().build("ElderCadet"); elder.buildChild().build("ZeElderCadet"); elder.buildChild().build("ElderElder"); elder.buildChild().build("AnElderCadet"); String hierarchy = scopeHierarchyToString(root); assertThat(hierarchy).isEqualTo("" + "Mortar Hierarchy:\n" + BLANK + "SCOPE Root\n" + BLANK + "+-SCOPE Cadet\n" + BLANK + "+-SCOPE Colonel\n" + BLANK + "| +-SCOPE ElderColonel\n" + BLANK + "| `-SCOPE ZeElderColonel\n" + BLANK + "`-SCOPE Elder\n" + BLANK + " +-SCOPE AnElderCadet\n" + BLANK + " +-SCOPE ElderCadet\n" + BLANK + " +-SCOPE ElderElder\n" + BLANK + " `-SCOPE ZeElderCadet\n" ); }
@Test public void startsFromMortarScope() { MortarScope root = MortarScope.buildRootScope().build("Root"); MortarScope child = root.buildChild().build("Child"); String hierarchy = scopeHierarchyToString(child); assertThat(hierarchy).isEqualTo("" + "Mortar Hierarchy:\n" + BLANK + "SCOPE Root\n" + BLANK + "`-SCOPE Child\n" ); }
@Test public void noSpaceAtLineBeginnings() { MortarScope root = MortarScope.buildRootScope().build("Root"); MortarScope child = root.buildChild().build("Child"); child.buildChild().build("Grand Child"); String hierarchy = scopeHierarchyToString(root); assertThat(hierarchy).isEqualTo("" + "Mortar Hierarchy:\n" + BLANK + "SCOPE Root\n" + BLANK + "`-SCOPE Child\n" + BLANK + " `-SCOPE Grand Child\n" ); }