public static NetworkService buildUriNetworkService(String uriString) {
    try {
      URI uri = new URI(uriString);
      NetworkEndpoint uriEndPoint = buildUriNetworkEndPoint(uri);

      return NetworkService.newBuilder()
          .setNetworkEndpoint(uriEndPoint)
          .setTransportProtocol(TransportProtocol.TCP)
          .setServiceName(uri.getScheme())
          .setServiceContext(
              ServiceContext.newBuilder()
                  .setWebServiceContext(
                      WebServiceContext.newBuilder().setApplicationRoot(uri.getPath())))
          .build();
    } catch (URISyntaxException exception) {
      throw new AssertionError(
          String.format(
              "Invalid uri syntax passed as target '%s'. Error: %s", uriString, exception));
    }
  }
@Test
  public void buildUriNetworkService_returnsNetworkService() throws IOException {

    URL url = new URL("https://localhost/function1");
    String hostname = url.getHost();
    String ipaddress = InetAddress.getByName(hostname).getHostAddress();
    InetAddress inetAddress = InetAddress.getByName(url.getHost());
    AddressFamily addressFamily =
        inetAddress instanceof Inet4Address ? AddressFamily.IPV4 : AddressFamily.IPV6;

    NetworkEndpoint networkEndpoint =
        NetworkEndpoint.newBuilder()
            .setType(NetworkEndpoint.Type.IP_HOSTNAME_PORT)
            .setIpAddress(
                IpAddress.newBuilder().setAddressFamily(addressFamily).setAddress(ipaddress))
            .setPort(Port.newBuilder().setPortNumber(443))
            .setHostname(Hostname.newBuilder().setName("localhost"))
            .build();

    NetworkService networkService =
        NetworkService.newBuilder()
            .setNetworkEndpoint(networkEndpoint)
            .setTransportProtocol(TransportProtocol.TCP)
            .setServiceName("https")
            .setServiceContext(
                ServiceContext.newBuilder()
                    .setWebServiceContext(
                        WebServiceContext.newBuilder().setApplicationRoot("/function1")))
            .build();

    assertThat(NetworkServiceUtils.buildUriNetworkService("https://localhost/function1"))
        .isEqualTo(networkService);
  }