@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(dataProvider = "badNodeUpdateTestCases")
  public void testHandleD2NodeUpdateWithBadData(DiscoveryResponseData badData, boolean nackExpected)
  {
    XdsClientImplFixture fixture = new XdsClientImplFixture();
    fixture._nodeSubscriber.setData(null);
    fixture._xdsClientImpl.handleResponse(badData);
    fixture.verifyAckOrNack(nackExpected, 1);
    verify(fixture._resourceWatcher).onChanged(eq(NODE.emptyData()));
    XdsClient.NodeUpdate actualData = (XdsClient.NodeUpdate) fixture._nodeSubscriber.getData();
    Assert.assertNull(Objects.requireNonNull(actualData).getNodeData());

    fixture._nodeSubscriber.setData(NODE_UPDATE1);
    fixture._xdsClientImpl.handleResponse(badData);
    fixture.verifyAckOrNack(nackExpected, 2);
    verify(fixture._resourceWatcher).onChanged(eq(NODE_UPDATE1));
    actualData = (XdsClient.NodeUpdate) fixture._nodeSubscriber.getData();
    // bad data will not overwrite the original valid data
    Assert.assertEquals(actualData.getNodeData(), NODE_UPDATE1.getNodeData());
  }