@Test
public void testMergeAllocateResponse() {

  ContainerId cid = ContainerId.newContainerId(attemptId, 0);
  ContainerStatus cStatus = Records.newRecord(ContainerStatus.class);
  cStatus.setContainerId(cid);
  Container container =
          Container.newInstance(cid, null, null, null, null, null);
  AllocateResponse homeResponse = Records.newRecord(AllocateResponse.class);
  homeResponse.setAllocatedContainers(Collections.singletonList(container));
  homeResponse.setCompletedContainersStatuses(
      Collections.singletonList(cStatus));
  homeResponse.setUpdatedNodes(
          Collections.singletonList(Records.newRecord(NodeReport.class)));
  homeResponse.setNMTokens(
          Collections.singletonList(Records.newRecord(NMToken.class)));
  homeResponse.setUpdatedContainers(
          Collections.singletonList(
              Records.newRecord(UpdatedContainer.class)));
  homeResponse.setUpdateErrors(Collections
          .singletonList(Records.newRecord(UpdateContainerError.class)));
  homeResponse.setAvailableResources(Records.newRecord(Resource.class));
  homeResponse.setPreemptionMessage(createDummyPreemptionMessage(
      ContainerId.newContainerId(attemptId, 0)));
  AllocateResponse response = Records.newRecord(AllocateResponse.class);
  response.setAllocatedContainers(Collections.singletonList(container));
  response.setCompletedContainersStatuses(Collections.singletonList(cStatus));
  response.setUpdatedNodes(
          Collections.singletonList(Records.newRecord(NodeReport.class)));
  response.setNMTokens(
          Collections.singletonList(Records.newRecord(NMToken.class)));
  response.setUpdatedContainers(
          Collections.singletonList(
              Records.newRecord(UpdatedContainer.class)));
  response.setUpdateErrors(Collections
          .singletonList(Records.newRecord(UpdateContainerError.class)));
  response.setAvailableResources(Records.newRecord(Resource.class));
  response.setPreemptionMessage(createDummyPreemptionMessage(
      ContainerId.newContainerId(attemptId, 1)));
  interceptor.mergeAllocateResponse(homeResponse,
      response, SubClusterId.newInstance("SC-1"));
  Assert.assertEquals(2,
      homeResponse.getPreemptionMessage().getContract()
          .getContainers().size());
  Assert.assertEquals(2,
      homeResponse.getAllocatedContainers().size());
  Assert.assertEquals(2,
      homeResponse.getUpdatedNodes().size());
  Assert.assertEquals(2,
      homeResponse.getCompletedContainersStatuses().size());
}