public void validateReadPermission(String serverUrl, String personalAccessToken) {
    HttpUrl url = buildUrl(serverUrl, "/rest/api/1.0/repos");
    doGet(personalAccessToken, url, body -> buildGson().fromJson(body, RepositoryList.class));
  }
@Test
  public void fail_validate_read_permission_when_permissions_are_not_granted() {
    server.enqueue(new MockResponse().setResponseCode(401)
      .setBody("com.atlassian.bitbucket.AuthorisationException You are not permitted to access this resource"));

    String serverUrl = server.url("/").toString();
    assertThatThrownBy(() -> underTest.validateReadPermission(serverUrl, "token"))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Invalid personal access token");
  }