@VisibleForTesting
  void handleResponse(DiscoveryResponseData response)
  {
    ResourceType resourceType = response.getResourceType();
    switch (resourceType)
    {
      case NODE:
        handleD2NodeResponse(response);
        break;
      case D2_URI_MAP:
        handleD2URIMapResponse(response);
        break;
      case D2_URI:
        handleD2URICollectionResponse(response);
        break;
      default:
        throw new AssertionError("Missing case in enum switch: " + resourceType);
    }
  }
@Test
  public void testHandleD2NodeResponseWithData()
  {
    XdsClientImplFixture fixture = new XdsClientImplFixture();
    // subscriber original data is null
    fixture._nodeSubscriber.setData(null);
    fixture._xdsClientImpl.handleResponse(DISCOVERY_RESPONSE_NODE_DATA1);
    fixture.verifyAckSent(1);
    verify(fixture._resourceWatcher).onChanged(eq(NODE_UPDATE1));
    verifyZeroInteractions(fixture._serverMetricsProvider); // initial update should not track latency
    XdsClient.NodeUpdate actualData = (XdsClient.NodeUpdate) fixture._nodeSubscriber.getData();
    // subscriber data should be updated to NODE_UPDATE1
    Assert.assertEquals(Objects.requireNonNull(actualData).getNodeData(), NODE_UPDATE1.getNodeData());

    // subscriber original data is invalid, xds server latency won't be tracked
    fixture._nodeSubscriber.setData(new XdsClient.NodeUpdate(null));
    fixture._xdsClientImpl.handleResponse(DISCOVERY_RESPONSE_NODE_DATA1);
    fixture.verifyAckSent(2);
    verify(fixture._resourceWatcher, times(2)).onChanged(eq(NODE_UPDATE1));
    verifyZeroInteractions(fixture._serverMetricsProvider);

    // subscriber data should be updated to NODE_UPDATE2
    fixture._xdsClientImpl.handleResponse(DISCOVERY_RESPONSE_NODE_DATA2);
    actualData = (XdsClient.NodeUpdate) fixture._nodeSubscriber.getData();
    verify(fixture._resourceWatcher).onChanged(eq(NODE_UPDATE2));
    verify(fixture._serverMetricsProvider).trackLatency(anyLong());
    Assert.assertEquals(actualData.getNodeData(), NODE_UPDATE2.getNodeData());
  }