@Test
  public void test() {
    ListApplicationsRequest request =
        new ListApplicationsRequest()
            .withId("test-id-1")
            .withIds(Collections.singletonList("test-id-2"))
            .withName("test-name-1")
            .withNames(Collections.singletonList("test-name-2"))
            .withOrganizationId("test-organization-id-1")
            .withOrganizationIds(Collections.singletonList("test-organization-id-2"))
            .withSpaceId("test-space-id-1")
            .withSpaceIds(Collections.singletonList("test-space-id-2"));

    assertEquals(Arrays.asList("test-id-1", "test-id-2"), request.getIds());
    assertEquals(Arrays.asList("test-name-1", "test-name-2"), request.getNames());
    assertEquals(
        Arrays.asList("test-organization-id-1", "test-organization-id-2"),
        request.getOrganizationIds());
    assertEquals(Arrays.asList("test-space-id-1", "test-space-id-2"), request.getSpaceIds());
  }
  public Request<ListApplicationsRequest> marshall(
      ListApplicationsRequest listApplicationsRequest) {

    if (listApplicationsRequest == null) {
      throw new AmazonClientException("Invalid argument passed to marshall(...)");
    }

    Request<ListApplicationsRequest> request =
        new DefaultRequest<ListApplicationsRequest>(listApplicationsRequest, "AmazonInspector");
    request.addHeader("X-Amz-Target", "InspectorService.ListApplications");

    request.setHttpMethod(HttpMethodName.POST);

    request.setResourcePath("");

    try {
      StringWriter stringWriter = new StringWriter();
      JSONWriter jsonWriter = new JSONWriter(stringWriter);

      jsonWriter.object();

      if (listApplicationsRequest.getFilter() != null) {
        jsonWriter.key("filter");
        ApplicationsFilterJsonMarshaller.getInstance()
            .marshall(listApplicationsRequest.getFilter(), jsonWriter);
      }

      if (listApplicationsRequest.getNextToken() != null) {
        jsonWriter.key("nextToken").value(listApplicationsRequest.getNextToken());
      }

      if (listApplicationsRequest.getMaxResults() != null) {
        jsonWriter.key("maxResults").value(listApplicationsRequest.getMaxResults());
      }

      jsonWriter.endObject();

      String snippet = stringWriter.toString();
      byte[] content = snippet.getBytes(UTF8);
      request.setContent(new StringInputStream(snippet));
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.addHeader("Content-Type", "application/x-amz-json-1.1");
    } catch (Throwable t) {
      throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t);
    }

    return request;
  }