@Before
  public void setup()
      throws NoPeerConnectionException, InvalidProcessStateException, ProcessExecutionException {
    // setup network
    network = NetworkTestUtil.createH2HNetwork(NETWORK_SIZE);
    // create some random user credentials
    userCredentials = H2HJUnitTest.generateRandomCredentials();
    // register and login a user (peer 0)
    uploaderRoot = FileTestUtil.getTempDirectory();
    uploader = network.get(0);
    uploader.getUserManager().createRegisterProcess(userCredentials).execute();
    uploader
        .getUserManager()
        .createLoginProcess(userCredentials, new TestFileAgent(uploaderRoot))
        .execute();

    // other client to verify this
    File downloaderRoot = FileTestUtil.getTempDirectory();
    downloader = network.get(1);
    downloader
        .getUserManager()
        .createLoginProcess(userCredentials, new TestFileAgent(downloaderRoot))
        .execute();

    nodeManager = Mockito.mock(INodeManager.class);
    Mockito.stub(nodeManager.getNode()).toReturn(uploader);
    UserConfig userConfig = Mockito.mock(UserConfig.class);
    Mockito.stub(userConfig.getRootPath()).toReturn(uploaderRoot.toPath());
    fileManager = new FileManager(nodeManager, userConfig);
  }
  @Test
  public void testCreateUserConfig_ByFile() {
    Path file = Paths.get(FileUtils.getTempDirectoryPath(), "userconfig_test.conf");

    UserConfig cfg = UserConfigUtils.createUserConfig(file);
    assertNotNull(cfg);
    assertEquals(file, cfg.getConfigFile());
  }
  @Test
  public void testCreateUserConfig_ByUsername() {
    String sha256 = "96d9632f363564cc3032521409cf22a852f2032eec099ed5967c0d000cec607a"; // John
    String username = "******";
    Path expectedFile = Paths.get(String.format("%s.conf", sha256));

    UserConfig cfg = UserConfigUtils.createUserConfig(username);
    assertNotNull(cfg);
    assertEquals(expectedFile, cfg.getConfigFile().getFileName());

    // lower
    cfg = UserConfigUtils.createUserConfig(username.toLowerCase());
    assertNotNull(cfg);
    assertEquals(expectedFile, cfg.getConfigFile().getFileName());

    // upper
    cfg = UserConfigUtils.createUserConfig(username.toUpperCase());
    assertNotNull(cfg);
    assertEquals(expectedFile, cfg.getConfigFile().getFileName());
  }
  @Test
  public void testGetAllConfigFiles() throws IOException {
    // user 1
    UserConfig cfgJohn = UserConfigUtils.createUserConfig("john");
    cfgJohn.load();
    cfgJohn.setUsername("john");

    // user 2
    UserConfig cfgSteven = UserConfigUtils.createUserConfig("steven");
    cfgSteven.load();
    cfgSteven.setUsername("steven");

    // search files
    Map<String, UserConfig> cfgFiles = UserConfigUtils.getAllConfigFiles();
    assertEquals(2, cfgFiles.size());

    assertTrue(cfgFiles.containsKey("john"));
    assertTrue(cfgFiles.containsKey("steven"));

    assertEquals("john", cfgFiles.get("john").getUsername());
    assertEquals("steven", cfgFiles.get("steven").getUsername());
  }