@Override
  public ImportResult importItem(
      UUID jobId,
      IdempotentImportExecutor executor,
      TokensAndUrlAuthData authData,
      SocialActivityContainerResource resource)
      throws Exception {
    if (resource == null) {
      // Nothing to import
      return ImportResult.OK;
    }

    monitor.debug(
        () -> String.format("Number of Posts: %d", resource.getCounts().get("activitiesCount")));

    final LongAdder totalImportedFilesSizes = new LongAdder();
    // Import social activity
    for (SocialActivityModel activity : resource.getActivities()) {
      if (activity.getType() == SocialActivityType.NOTE
          || activity.getType() == SocialActivityType.POST) {
        executor.importAndSwallowIOExceptions(
            activity,
            currentActivity -> {
              ItemImportResult<String> insertActivityResult = insertActivity(activity, authData);
              if (insertActivityResult != null && insertActivityResult.hasBytes()) {
                totalImportedFilesSizes.add(insertActivityResult.getBytes());
              }
              return insertActivityResult;
            });
      }
    }

    return ImportResult.OK.copyWithBytes(totalImportedFilesSizes.longValue());
  }
@Test
  public void testImportSingleActivity() throws Exception {
    String postContent = "activityContent";
    SocialActivityModel activity =
        new SocialActivityModel(
            "activityId",
            Instant.now(),
            SocialActivityType.POST,
            Collections.emptyList(),
            new SocialActivityLocation("test", 1.1, 2.2),
            "activityTitle",
            postContent,
            "activityUrl");
    SocialActivityContainerResource resource =
        new SocialActivityContainerResource(
            "123",
            new SocialActivityActor("321", "John Doe", "url"),
            Collections.singletonList(activity));

    Call call = mock(Call.class);
    Response dummySuccessfulResponse =
        new Response.Builder()
            .code(200)
            .request(new Request.Builder().url("http://example.com").build())
            .protocol(Protocol.HTTP_1_1)
            .message("all good!")
            .body(ResponseBody.create(MediaType.parse("text/xml"), "<a>ok!</a>"))
            .build();
    when(call.execute()).thenReturn(dummySuccessfulResponse);
    when(client.newCall(any())).thenReturn(call);

    DaybookPostsImporter importer =
        new DaybookPostsImporter(
            monitor, client, new ObjectMapper(), "http://example.com", "export-service");
    importer.importItem(UUID.randomUUID(), executor, authData, resource);
    ArgumentCaptor<Request> requestCaptor = ArgumentCaptor.forClass(Request.class);
    verify(client, times(1)).newCall(requestCaptor.capture());

    RequestBody untypedBody = requestCaptor.getValue().body();
    assertTrue(untypedBody instanceof FormBody);
    FormBody actual = (FormBody) untypedBody;
    assertEquals(
        "DaybookPostsImporter changed the order of fields in the body.", "content", actual.name(2));
    assertEquals(postContent, actual.value(2));
  }