@Test
  public void shouldConnectWithCredentials() throws IOException {
    HttpConnectionUtil httpConnectionUtil = mockConnection();
    Rules rules = new Rules();
    Server server = new Server(rules, httpConnectionUtil);
    rules.setGoLogin("login");
    rules.setGoPassword("pass");

    HttpURLConnection conn = mock(HttpURLConnection.class);
    when(httpConnectionUtil.getConnection(any(URL.class))).thenReturn(conn);
    when(conn.getContent()).thenReturn(new Object());

    server.getUrl(new URL("http://exmaple.org/"));

    verify(conn).setRequestProperty("Authorization", "Basic bG9naW46cGFzcw==");
  }
  @Test
  public void shouldNotConnectWithEmptyPassword() throws IOException {
    HttpConnectionUtil httpConnectionUtil = mockConnection();
    Rules rules = new Rules();
    rules.setGoLogin("login");
    rules.setGoPassword(null);
    Server server = new Server(rules, httpConnectionUtil);

    HttpURLConnection conn = mock(HttpURLConnection.class);
    when(httpConnectionUtil.getConnection(any(URL.class))).thenReturn(conn);
    when(conn.getContent()).thenReturn(new Object());

    server.getUrl(new URL("http://exmaple.org/"));

    verify(conn, never()).setRequestProperty(anyString(), anyString());
  }
  @Test
  public void testGetPipelineInstance() throws Exception {
    HttpConnectionUtil httpConnectionUtil = mockConnection();

    Rules rules = new Rules();
    rules.setGoServerHost("https://example.org");
    Server server = new Server(rules, httpConnectionUtil);

    server.getPipelineInstance("pipeline-test", 42);

    ArgumentCaptor<URL> url = ArgumentCaptor.forClass(URL.class);
    verify(httpConnectionUtil).getConnection(url.capture());
    assertThat(
        url.getValue().toString(),
        is("https://example.org/go/api/pipelines/pipeline-test/instance/42"));
  }