@Test
  public void testDatasetTtl() throws Exception {
    //Add dataset with ttl 0, should return bad request
    Account testAccount = new ArrayList<>(accountService.getAllAccounts()).get(1);
    Container testContainer = new ArrayList<>(testAccount.getAllContainers()).get(1);
    Dataset.VersionSchema versionSchema = Dataset.VersionSchema.TIMESTAMP;
    Dataset dataset =
        new DatasetBuilder(testAccount.getName(), testContainer.getName(), DATASET_NAME).setVersionSchema(versionSchema)
            .setRetentionTimeInSeconds(0L)
            .build();

    byte[] datasetsUpdateJson = AccountCollectionSerde.serializeDatasetsInJson(dataset);
    ObjectMapper mapper = new ObjectMapper();
    Map<String, Object> map =
        mapper.readValue(new String(datasetsUpdateJson), new TypeReference<Map<String, Object>>() {
        });
    assertFalse("Should not contain null(default) value after serialization", map.containsKey("retentionCount"));
    assertEquals("Serialized value mismatch", 0, map.get("retentionTimeInSeconds"));

    List<ByteBuffer> body = new LinkedList<>();
    body.add(ByteBuffer.wrap(datasetsUpdateJson));
    body.add(null);
    JSONObject headers = new JSONObject().put(RestUtils.Headers.TARGET_ACCOUNT_NAME, testAccount.getName())
        .put(RestUtils.Headers.TARGET_CONTAINER_NAME, testContainer.getName());
    RestRequest restRequest =
        createRestRequest(RestMethod.POST, Operations.ACCOUNTS_CONTAINERS_DATASETS, headers, body);
    //verify status.
    verifyOperationFailure(restRequest, RestServiceErrorCode.BadRequest);

    //Add dataset with retention count equals 0, should return bad request
    dataset =
        new DatasetBuilder(testAccount.getName(), testContainer.getName(), DATASET_NAME).setVersionSchema(versionSchema)
            .setRetentionCount(0)
            .build();
    datasetsUpdateJson = AccountCollectionSerde.serializeDatasetsInJson(dataset);
    map = mapper.readValue(new String(datasetsUpdateJson), new TypeReference<Map<String, Object>>() {
    });
    assertFalse("Should not contain null(default) value after serialization",
        map.containsKey("retentionTimeInSeconds"));
    assertEquals("Serialized value mismatch", 0, map.get("retentionCount"));

    body = new LinkedList<>();
    body.add(ByteBuffer.wrap(datasetsUpdateJson));
    body.add(null);
    restRequest = createRestRequest(RestMethod.POST, Operations.ACCOUNTS_CONTAINERS_DATASETS, headers, body);
    verifyOperationFailure(restRequest, RestServiceErrorCode.BadRequest);

    //add valid dataset
    dataset =
        new DatasetBuilder(testAccount.getName(), testContainer.getName(), DATASET_NAME).setVersionSchema(versionSchema)
            .build();
    datasetsUpdateJson = AccountCollectionSerde.serializeDatasetsInJson(dataset);
    body = new LinkedList<>();
    body.add(ByteBuffer.wrap(datasetsUpdateJson));
    body.add(null);
    restRequest = createRestRequest(RestMethod.POST, Operations.ACCOUNTS_CONTAINERS_DATASETS, headers, body);
    RestResponseChannel restResponseChannel = new MockRestResponseChannel();
    doOperation(restRequest, restResponseChannel);

    //update dataset with ttl 0
    dataset =
        new DatasetBuilder(testAccount.getName(), testContainer.getName(), DATASET_NAME).setVersionSchema(versionSchema)
            .setRetentionTimeInSeconds(0L)
            .build();
    datasetsUpdateJson = AccountCollectionSerde.serializeDatasetsInJson(dataset);
    body = new LinkedList<>();
    body.add(ByteBuffer.wrap(datasetsUpdateJson));
    body.add(null);
    headers.put(DATASET_UPDATE, "true");
    restRequest = createRestRequest(RestMethod.POST, Operations.ACCOUNTS_CONTAINERS_DATASETS, headers, body);
    verifyOperationFailure(restRequest, RestServiceErrorCode.BadRequest);
  }
Tests blob POST, GET, HEAD, TTL update and DELETE operations.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java