private List<RemoteRunnerServer> createRunners() throws Exception {
    List<RemoteRunnerServer> servers = new ArrayList<>(1);
    RemoteRunnerServer server1 = mock(RemoteRunnerServer.class);
    doReturn(true).when(server1).isAvailable();
    servers.add(server1);
    List<RunnerDescriptor> runners1 = new ArrayList<>(1);
    RunnerDescriptor runner1 = dto(RunnerDescriptor.class).withName("java/web");
    runner1.getEnvironments().add(dto(RunnerEnvironment.class).withId("my_tomcat7"));
    runner1.getEnvironments().add(dto(RunnerEnvironment.class).withId("my_jboss7"));
    runners1.add(runner1);

    RemoteRunnerServer server2 = mock(RemoteRunnerServer.class);
    doReturn(true).when(server2).isAvailable();
    servers.add(server2);
    List<RunnerDescriptor> runners2 = new ArrayList<>(1);
    RunnerDescriptor runner2 = dto(RunnerDescriptor.class).withName("java/web");
    runner2.getEnvironments().add(dto(RunnerEnvironment.class).withId("tomcat7"));
    runner2.getEnvironments().add(dto(RunnerEnvironment.class).withId("jboss7"));
    runners2.add(runner2);

    doReturn(runners1).when(server1).getRunnerDescriptors();
    doReturn(runners2).when(server2).getRunnerDescriptors();
    doReturn(servers).when(runQueue).getRegisterRunnerServers();
    return servers;
  }
  @Test
  public void testGetRunnerEnvironments() throws Exception {
    List<RemoteRunnerServer> servers = new ArrayList<>(1);
    RemoteRunnerServer server1 = mock(RemoteRunnerServer.class);
    doReturn(true).when(server1).isAvailable();
    servers.add(server1);
    List<RunnerDescriptor> runners1 = new ArrayList<>(1);
    RunnerDescriptor runner1 = dto(RunnerDescriptor.class).withName("java/web");
    runner1.getEnvironments().add(dto(RunnerEnvironment.class).withId("tomcat7"));
    runner1.getEnvironments().add(dto(RunnerEnvironment.class).withId("jboss7"));
    runners1.add(runner1);

    RemoteRunnerServer server2 = mock(RemoteRunnerServer.class);
    doReturn(true).when(server2).isAvailable();
    servers.add(server2);
    List<RunnerDescriptor> runners2 = new ArrayList<>(1);
    RunnerDescriptor runner2 = dto(RunnerDescriptor.class).withName("java/web");
    runner2.getEnvironments().add(dto(RunnerEnvironment.class).withId("tomcat7"));
    runner2.getEnvironments().add(dto(RunnerEnvironment.class).withId("jboss7"));
    runners2.add(runner2);

    doReturn(runners1).when(server1).getRunnerDescriptors();
    doReturn(runners2).when(server2).getRunnerDescriptors();
    doReturn(servers).when(runQueue).getRegisterRunnerServers();

    RunnerEnvironmentTree system = service.getRunnerEnvironments(null, null);
    assertEquals(system.getDisplayName(), "system");
    assertEquals(system.getLeaves().size(), 0);
    List<RunnerEnvironmentTree> nodes = system.getNodes();
    assertEquals(nodes.size(), 1);

    RunnerEnvironmentTree java = system.getNode("java");
    assertNotNull(java);
    assertEquals(java.getDisplayName(), "java");
    nodes = java.getNodes();
    assertEquals(nodes.size(), 1);
    assertEquals(java.getLeaves().size(), 0);

    RunnerEnvironmentTree web = java.getNode("web");
    assertNotNull(web);
    assertEquals(web.getNodes().size(), 0);
    assertEquals(web.getLeaves().size(), 2);
    RunnerEnvironmentLeaf tomcat7 = web.getEnvironment("tomcat7");
    assertNotNull(tomcat7);
    RunnerEnvironmentLeaf jboss7 = web.getEnvironment("jboss7");
    assertNotNull(jboss7);
    RunnerEnvironment tomcat7Environment = tomcat7.getEnvironment();
    RunnerEnvironment jboss7Environment = jboss7.getEnvironment();
    assertNotNull(tomcat7Environment);
    assertNotNull(jboss7Environment);
    assertEquals(tomcat7Environment.getId(), "system:/java/web/tomcat7");
    assertEquals(jboss7Environment.getId(), "system:/java/web/jboss7");
  }