### Question:
Configurations implements TabWidthAndBaseDirProvider { public int tabWidth() { for (final Configuration currentChild : rootElement.getChildren()) { if (TREE_WALKER_ELEMENT.equals(currentChild.getName())) { return intValueOrDefault(getAttributeOrNull(currentChild, "tabWidth"), defaultTabSize()); } } return defaultTabSize(); } Configurations(@Nullable final Module module, @NotNull final Configuration rootElement); int tabWidth(); Optional<String> baseDir();  }### Answer:
@Test public void tabWidthNullAttribute() throws IOException { final Configuration config = ConfigurationBuilder.checker().withChild( ConfigurationBuilder.config("TreeWalker").withAttribute("tabWidth", null)).build(); assertEquals(CODE_STYLE_TAB_SIZE, createClassUnderTest(config).tabWidth()); }
@Test public void aDefaultTabWidthIsEightIsUsedWhenNoTabWidthPropertyIsPresent() throws IOException { final Configuration config = ConfigurationBuilder.checker().build(); assertEquals(CODE_STYLE_TAB_SIZE, createClassUnderTest(config).tabWidth()); }
@Test public void testNoTreeWalker_useDefault() throws IOException { final Configuration config = ConfigurationBuilder.checker().withChild( ConfigurationBuilder.config("FileTabCharacter")).build(); assertEquals(CODE_STYLE_TAB_SIZE, createClassUnderTest(config).tabWidth()); }
@Test public void tabWidthPropertyValueIsReturnedWhenPresent() throws IOException { final Configuration config = ConfigurationBuilder.checker().withChild( ConfigurationBuilder.config("TreeWalker").withAttribute("tabWidth", "7")).build(); assertEquals(7, createClassUnderTest(config).tabWidth()); }
@Test public void aTabWidthPropertyWithANonIntegerValueReturnsTheDefault() throws IOException { final Configuration config = ConfigurationBuilder.checker().withChild( ConfigurationBuilder.config("TreeWalker").withAttribute("tabWidth", "dd")).build(); assertEquals(CODE_STYLE_TAB_SIZE, createClassUnderTest(config).tabWidth()); }
@Test public void aTabWidthPropertyWithNoValueReturnsTheDefault() throws IOException { final Configuration config = ConfigurationBuilder.checker().withChild( ConfigurationBuilder.config("TreeWalker").withAttribute("tabWidth", "")).build(); assertEquals(CODE_STYLE_TAB_SIZE, createClassUnderTest(config).tabWidth()); }