### Question:
StructureBuildingMethods { static String checkForBracketedPrimedLocantSpecialCase(Element subBracketOrRoot, String locantString) { int terminalPrimes = StringTools.countTerminalPrimes(locantString); if (terminalPrimes > 0){ int brackettingDepth = 0; Element parent = subBracketOrRoot.getParent(); while (parent != null && parent.getName().equals(BRACKET_EL)){ if (!IMPLICIT_TYPE_VAL.equals(parent.getAttributeValue(TYPE_ATR))){ brackettingDepth++; } parent = parent.getParent(); } if (terminalPrimes == brackettingDepth){ return locantString.substring(0, locantString.length() - terminalPrimes); } } return null; } private  StructureBuildingMethods();   }### Answer:
@Test public void bracketedPrimeSpecialCase2() { Element word = new GroupingEl(WORD_EL); Element bracket = new GroupingEl(BRACKET_EL); word.addChild(bracket); Element bracket2 = new GroupingEl(BRACKET_EL); bracket.addChild(bracket2); Element substituent = new GroupingEl(SUBSTITUENT_EL); bracket2.addChild(substituent); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals("4", StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); bracket2.addAttribute(new Attribute(TYPE_ATR, IMPLICIT_TYPE_VAL)); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals("4", StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); }
@Test public void bracketedPrimeNotSpecialCase() { Element word = new GroupingEl(WORD_EL); Element substituent = new GroupingEl(SUBSTITUENT_EL); word.addChild(substituent); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); }
@Test public void bracketedPrimeSpecialCase1() { Element word = new GroupingEl(WORD_EL); Element bracket = new GroupingEl(BRACKET_EL); word.addChild(bracket); Element substituent = new GroupingEl(SUBSTITUENT_EL); bracket.addChild(substituent); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals("4", StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); bracket.addAttribute(new Attribute(TYPE_ATR, IMPLICIT_TYPE_VAL)); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4'")); assertEquals(null, StructureBuildingMethods.checkForBracketedPrimedLocantSpecialCase(substituent, "4''")); }