@Test
  public void doFileCopyChunkRequestTest() throws IOException {
    short requestVersionToUse = FileCopyGetChunkRequest.CURRENT_VERSION;
    FileCopyGetChunkRequest request = new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1",
        new MockPartitionId(), "0_0_log", "host1", "snapshotId", 1000,
        100, false);
    DataInputStream requestStream = serAndPrepForRead(request, -1, true);
    FileCopyGetChunkRequest deserialisedRequest = FileCopyGetChunkRequest.readFrom(requestStream, new MockClusterMap());

    Assert.assertEquals("0_0_log", deserialisedRequest.getFileName());
    Assert.assertEquals(100, deserialisedRequest.getChunkLengthInBytes());
    Assert.assertEquals(0, deserialisedRequest.getPartitionId().getId());
    Assert.assertEquals("0", deserialisedRequest.getPartitionId().toPathString());
    Assert.assertEquals(111, deserialisedRequest.getCorrelationId());
    Assert.assertEquals(1000, deserialisedRequest.getStartOffset());
    Assert.assertEquals(requestVersionToUse, deserialisedRequest.getVersionId());
    Assert.assertEquals(false, deserialisedRequest.isChunked());
    request.release();

    try {
      // Sending CURRENT_VERSION + 1 as version. Expected to throw exception.
      new FileCopyGetChunkRequest((short) (FileCopyGetChunkRequest.CURRENT_VERSION + 1),
          111, "id1", new MockPartitionId(), "0_0_log", "host1",
          "snapshotId", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e) {
      //expected
    }
    try {
      // Sending null partition id. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", null, "0_0_log",
          "host1", "snapshotId", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (NullPointerException e){
      //expected
    }
    try {
      // Sending empty file name. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(), "",
          "host1", "snapshotId", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending empty hostName. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(), "",
          "", "snapshotId", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending empty snapshotId. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(), "",
          "host1", "", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending negative start offset. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_log", "host1", "snapshotId", -1, 0, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending negative chunk size. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_log", "host1", "snapshotId", 1000, -1, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending 0 chunk size. Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_log", "host1", "snapshotId", 1000, 0, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending filename "some_random_file". Expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "some_random_file", "host1", "snapshotId", 1000, 100, false);
      Assert.fail("Should have failed");
    } catch (IllegalArgumentException e){
      //expected
    }
    try {
      // Sending request for logsegment `0_0_log`. Not expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_log", "host1", "snapshotId", 1000, 100, false);
    } catch (IllegalArgumentException e){
      Assert.fail("Not expected to fail");
    }
    try {
      // Sending request for logsegment `0_0_bloom`. Not expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_bloom", "host1", "snapshotId", 1000, 100, false);
    } catch (IllegalArgumentException e){
      Assert.fail("Not expected to fail");
    }
    try {
      // Sending request for logsegment `0_0_index`. Not expected to throw exception.
      new FileCopyGetChunkRequest(requestVersionToUse, 111, "id1", new MockPartitionId(),
          "0_0_index", "host1", "snapshotId", 1000, 100, false);
    } catch (IllegalArgumentException e){
      Assert.fail("Not expected to fail");
    }
  }
Test the {@link StoreFileChunk#from} method.
@throws IOException
ambry-protocol/src/test/java/com/github/ambry/protocol/RequestResponseTest.java