public String getCallbackUri(String secretString) {
    String cbid = cbidGenerator.generate(secretString);

    if (!isValidPortNumber(callbackPort)) {
      throw new AssertionError("Invalid callbackPort number specified");
    }

    HostAndPort hostAndPort =
        callbackPort == 80
            ? HostAndPort.fromHost(callbackAddress)
            : HostAndPort.fromParts(callbackAddress, callbackPort);

    // check if the specified address is raw IP or domain
    if (InetAddresses.isInetAddress(callbackAddress)) {
      return CbidProcessor.addCbidToUrl(cbid, hostAndPort);
    } else if (InternetDomainName.isValid(callbackAddress)) {
      return CbidProcessor.addCbidToSubdomain(cbid, hostAndPort);
    }
    // Should never reach here
    throw new AssertionError("Unrecognized address format, should be Ip address or valid domain");
  }
@Test
  public void getCallbackUri_callbackPortIs80_returnsUriWithoutPortNum() {
    client = new TcsClient(VALID_IPV4_ADDRESS, 80, VALID_URL, httpClient);

    String url = client.getCallbackUri(SECRET);

    String expectedUriString = String.format("http://%s/%s", VALID_IPV4_ADDRESS, CBID);
    assertThat(url).isEqualTo(expectedUriString);
  }