### Question:
ProcessInfo { public String getName() { return name; } protected  ProcessInfo();  ProcessInfo(long pid);  ProcessInfo(long pid, SigarProxy sigar); void refresh(); ProcessInfoSnapshot priorSnaphot(); ProcessInfoSnapshot freshSnapshot(); void destroy(); long getPid(); String getName(); String getBaseName(); String[] getCommandLine(); Map<String, String> getEnvironmentVariables(); @Nullable String getEnvironmentVariable(@NotNull
    String name); @Deprecated long getParentPid(); @Deprecated ProcState getState(); @Deprecated ProcExe getExecutable(); @Deprecated ProcTime getTime(); @Deprecated ProcMem getMemory(); @Deprecated ProcCpu getCpu(); @Deprecated ProcFd getFileDescriptor(); @Deprecated ProcCred getCredentials(); @Deprecated ProcCredName getCredentialsName(); @Deprecated String getCurrentWorkingDirectory(); @Deprecated boolean isRunning(); AggregateProcessInfo getAggregateProcessTree(); ProcessInfo getParentProcess(); void kill(String signalName); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }### Answer:
@Test public void testGetNameDefault() { assertEquals(processInfo.getName(), "?"); }
@Test public void testGetNameFromArgs() throws Exception { when(sigarProxy.getProcArgs(PID)).thenReturn(new String[] { "onearg", "somearg", "otherarg" }); processInfo = new ProcessInfo(PID, sigarProxy); assertEquals(processInfo.getName(), "onearg"); }
@Test public void testGetNameFromExe() throws Exception { procExe = Mockito.mock(ProcExe.class); when(procExe.getName()).thenReturn("aprocname"); when(sigarProxy.getProcExe(PID)).thenReturn(procExe); processInfo = new ProcessInfo(PID, sigarProxy); assertEquals(processInfo.getName(), "aprocname"); }
@Test public void testGetNameFromStateWithFileNotExists() throws Exception { procState = Mockito.mock(ProcState.class); when(procState.getName()).thenReturn("/this/file/should/not/exists"); when(sigarProxy.getProcState(PID)).thenReturn(procState); processInfo = new ProcessInfo(PID, sigarProxy); assertEquals(processInfo.getName(), "/this/file/should/not/exists"); }
@Test public void testGetNameFromStateWithFileExists() throws Exception { File tmpFile = File.createTempFile("ProcessInfoTest-", ".tmp"); tmpFile.deleteOnExit(); procState = Mockito.mock(ProcState.class); when(procState.getName()).thenReturn(tmpFile.getAbsolutePath()); when(sigarProxy.getProcState(PID)).thenReturn(procState); processInfo = new ProcessInfo(PID, sigarProxy); assertEquals(processInfo.getName(), tmpFile.getAbsolutePath()); }