### Question:
ScenariooDataPathLogic { String getDataPath(final ServletContext servletContext) { String configSource = "servlet context"; String configurationDirectory = servletContext.getInitParameter( "scenariooDataDirectory"); if (StringUtils.isBlank(configurationDirectory)) { configSource = "SCENARIOO_DATA environment variable or scenarioo.data application property"; configurationDirectory = systemEnvironment.getScenariooDataDirectory(); } if (StringUtils.isBlank(configurationDirectory)) { configSource = "default scenarioo data directory"; configurationDirectory = new File(systemEnvironment.getUserHome(), USER_HOME_BASE_DIRECTORY).getAbsolutePath(); } LOGGER.info(" Taking documentation data path from " + configSource + ": " + configurationDirectory); return configurationDirectory; } ScenariooDataPathLogic(final SystemEnvironment systemEnvironment);   }### Answer:
@Test void getDocumentationPath_GivenServletConfigAndEnvVariable_ChosesServletContextFirst() { when(servletContext.getInitParameter("scenariooDataDirectory")).thenReturn("tmp/test"); when(systemEnvironment.getScenariooDataDirectory()).thenReturn("tmp/itShouldNotBeMe"); String actual = logic.getDataPath(servletContext); assertEquals("tmp/test", actual); }
@Test void getDocumentationPath_WhenServletContextParamIsNotPresent_ChosesEnvironmentVariable() { when(servletContext.getInitParameter("scenariooDataDirectory")).thenReturn(null); when(systemEnvironment.getScenariooDataDirectory()).thenReturn("tmp/test"); String actual = logic.getDataPath(servletContext); assertEquals("tmp/test", actual); }
@Test void getDocumentationPath_WhenNoExternalConfigurationIsGiven_DefaultsToScenariooHomeFolder() { when(servletContext.getInitParameter("scenariooDataDirectory")).thenReturn(null); when(systemEnvironment.getScenariooDataDirectory()).thenReturn(null); when(systemEnvironment.getUserHome()).thenReturn("/home/someuser"); String expectedPath = new File("/home/someuser/.scenarioo").getAbsolutePath(); String actual = logic.getDataPath(servletContext); assertEquals(expectedPath, actual); }