package org.sagebionetworks.bridge.sdk.integration;

import org.joda.time.LocalDate;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import org.sagebionetworks.bridge.rest.api.UsersApi;
import org.sagebionetworks.bridge.rest.model.DateRange;

// We don't currently have a way to hook into an email address to see the result. For now, just make sure that the call
// to the API succeeds and doesn't throw.
public class UserDataDownloadTest {
    private static TestUserHelper.TestUser user;

    @BeforeClass
    public static void setup() throws Exception {
        user = TestUserHelper.createAndSignInUser(UserDataDownloadTest.class, true);
    }

    @AfterClass
    public static void deleteUser() throws Exception {
        if (user != null) {
            user.signOutAndDeleteUser();
        }
    }

    @Test
    public void withBody() throws Exception {
        LocalDate todaysDate = LocalDate.now();
        DateRange dateRange = new DateRange().startDate(todaysDate).endDate(todaysDate);
        user.getClient(UsersApi.class).emailDataToUser(dateRange).execute();
    }
}

@@ -46,16 +46,62 @@
 ation;%0A%0A
+import static org.junit.Assert.assertEquals;%0A%0A
 import o
@@ -124,16 +124,16 @@
 alDate;%0A
-
 import o
@@ -205,16 +205,43 @@
 it.Test;
+%0Aimport retrofit2.Response;
 %0A%0Aimport
@@ -287,16 +287,16 @@
 ersApi;%0A
-
 import o
@@ -342,16 +342,70 @@
 teRange;
+%0Aimport org.sagebionetworks.bridge.rest.model.Message;
 %0A%0A// We 
@@ -1158,24 +1158,53 @@
 te);%0A       
+ Response%3CMessage%3E response =
  user.getCli
@@ -1257,20 +1257,64 @@
 .execute();%0A
+        assertEquals(202, response.code());%0A
     %7D%0A%7D%0A

check 202 response code for UDD