### Question:
OpsLoggerFactory { public OpsLoggerFactory setPath(Path path) { validateParametersForSetPath(path); clearCachedInstance(); logfilePath = Optional.of(path).map(Path::toAbsolutePath); loggerOutput = Optional.empty(); return this; }  OpsLoggerFactory setDestination(PrintStream printStream); OpsLoggerFactory setPath(Path path); OpsLoggerFactory setStoreStackTracesInFilesystem(boolean store); OpsLoggerFactory setStackTraceStoragePath(Path directory); OpsLoggerFactory setErrorHandler(Consumer<Throwable> handler); @Deprecated OpsLoggerFactory setCorrelationIdSupplier(Supplier<Map<String,String>> supplier); OpsLoggerFactory setGlobalDiagnosticContextSupplier(DiagnosticContextSupplier supplier); OpsLoggerFactory setAsync(boolean async); @SuppressWarnings("unchecked") OpsLogger<T> build();  }### Answer:
@Test public void setPath_shouldThrowAnException_givenANullPath() throws Exception { try { factory.setPath(null); fail("Expected an exception"); } catch (NullPointerException expected) { assertThat(expected.getMessage(), containsString("must not be null")); } }
@Test public void setPath_shouldThrowAnException_givenAPathThatIsADirectory() throws Exception { Path directory = Paths.get(System.getProperty("java.io.tmpdir")); assertTrue("precondition: must be a directory", Files.isDirectory(directory)); try { factory.setPath(directory); fail("Expected an exception"); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage(), containsString("must not be a directory")); } }
@Test public void setPath_shouldNotCreateAFileOrParentDirectory_whenBuildIsNotCalled() throws Exception { Path parent = tempFiles.createTempDirectoryThatDoesNotExist(); Path logFile = tempFiles.register(parent.resolve("log.txt")); assertFalse(Files.exists(parent)); assertFalse(Files.exists(logFile)); new OpsLoggerFactory() .setPath(logFile); assertFalse(Files.exists(parent)); assertFalse(Files.exists(logFile)); }