AutomaticTerminalOpener implements TerminalOpener { @Override public void openTerminal(String workingDirectory, Map<String, String> environmentVariables) { terminalOpener.openTerminal(workingDirectory, environmentVariables); } AutomaticTerminalOpener(
            TerminalOpenerFactory terminalOpenerFactory,
            OperatingSystemFetcher operatingSystemFetcher,
            Optional<String> linuxTerminalCommand);  AutomaticTerminalOpener(
            TerminalOpenerFactory terminalOpenerFactory,
            OperatingSystemFetcher operatingSystemFetcher); @Override void openTerminal(String workingDirectory, Map<String, String> environmentVariables);  }
@Test public void openTerminalTestOSX() { when(mockOperatingSystemFetcher.fetchCurrentOperationSystem()).thenReturn(OperatingSystem.MACOSX); final AutomaticTerminalOpener automaticTerminalOpener = new AutomaticTerminalOpener(mockTerminalOpenerFactory, mockOperatingSystemFetcher); final Map<String, String> map = new HashMap<>(); automaticTerminalOpener.openTerminal("workingDirectory", map); verify(mockMacTerminalOpener).openTerminal("workingDirectory", map); verifyNoMoreInteractions(mockLinuxTerminalOpener, mockMacTerminalOpener); }
@Test public void openTerminalTestLinux() { when(mockOperatingSystemFetcher.fetchCurrentOperationSystem()).thenReturn(OperatingSystem.LINUX); final AutomaticTerminalOpener automaticTerminalOpener = new AutomaticTerminalOpener(mockTerminalOpenerFactory, mockOperatingSystemFetcher); final Map<String, String> map = new HashMap<>(); automaticTerminalOpener.openTerminal("workingDirectory", map); verify(mockLinuxTerminalOpener).openTerminal("workingDirectory", map); verifyNoMoreInteractions(mockLinuxTerminalOpener, mockMacTerminalOpener); }