@Test
public void logResultsForBundle() throws Exception {

  File bundle = TestUtils.getTestDataFile("app.aab");
  ImmutableList<Suggestion> suggestions = ImmutableList.of(
      Suggestion.create(
          IssueType.WEBP,
          Category.WEBP,
          SOME_PAYLOAD,
          SOME_MESSAGE,
          1000L,
          /* autoFix= */ null));
  telemetryLogger.logResultsForBundle(bundle, suggestions);
  assertThat(clearcutConnection.getHeadersSetByClient().get("Cookie")).contains("NID=");
  LogRequest logRequest = inflatePayload(clearcutConnection);
  assertCommonLogFields(logRequest);
  SizeAnalysisLog sizeAnalysisLog = extractSourceExtension(logRequest);
  assertThat(sizeAnalysisLog.getAnalyzerVersion()).isEqualTo(Version.CURRENT_VERSION);
  assertThat(sizeAnalysisLog.getArtifactType()).isEqualTo(ArtifactType.APP_BUNDLE);
  assertThat(sizeAnalysisLog.getErrorType()).isEqualTo(ErrorType.NO_ERROR);
  assertThat(sizeAnalysisLog.getSuggestionsByIssueTypeList())
      .containsExactly(
          SuggestionsByIssueType.newBuilder()
              .setCategory("WEBP")
              .setIssueType("WEBP")
              .setSuggestionCount(1)
              .setEstimatedSavingsBytes(1000)
              .build());
  // Note that these sizes are truncated to multiples of 1000 bytes.
  // aab: 1408431
  // res files: 363900
  // dex files: 2211248
  // resources.pb: 462708
  assertThat(sizeAnalysisLog.getBundleSizeBreakdown())
      .isEqualTo(
          BundleSizeBreakdown.newBuilder()
              .setAabFileBytes(1408000)
              .setDexBytes(2211000)
              .setResourceFileBytes(363000)
              .setResourcePbBytes(462000)
              .build());
}