@Test
  public void convertToStrTest() throws Exception {
    String template = "RestRequest: [Method: %s, Path: %s, Uri: %s, Account: %s, Container: %s]";
    String method = RestMethod.GET.name();
    String uri = "/";
    Account account = InMemAccountService.UNKNOWN_ACCOUNT;
    Container container = Container.UNKNOWN_CONTAINER;

    // Test with no null values.
    RestRequest restRequest =
        createRestRequest(method, "/", InMemAccountService.UNKNOWN_ACCOUNT, Container.UNKNOWN_CONTAINER);
    String s = RestUtils.convertToStr(restRequest);
    assertEquals(String.format(template, method, uri, uri, account.toString(), container.toString()), s);

    // Test with null method.
    restRequest = createRestRequest(null, "/", InMemAccountService.UNKNOWN_ACCOUNT, Container.UNKNOWN_CONTAINER);
    s = RestUtils.convertToStr(restRequest);
    assertEquals(String.format(template, "null", uri, uri, account.toString(), container.toString()), s);

    // Test with null uri.
    restRequest = createRestRequest(method, null, InMemAccountService.UNKNOWN_ACCOUNT, Container.UNKNOWN_CONTAINER);
    s = RestUtils.convertToStr(restRequest);
    assertEquals(String.format(template, method, "null", "null", account.toString(), container.toString()), s);

    // Test with null account.
    restRequest = createRestRequest(method, uri, null, Container.UNKNOWN_CONTAINER);
    s = RestUtils.convertToStr(restRequest);
    assertEquals(String.format(template, method, uri, uri, "null", container.toString()), s);

    // Test with null container.
    restRequest = createRestRequest(method, uri, account, null);
    s = RestUtils.convertToStr(restRequest);
    assertEquals(String.format(template, method, uri, uri, account, "null"), s);
  }
Test request is upload request.
@throws Exception
ambry-api/src/test/java/com/github/ambry/rest/RestUtilsTest.java