package org.hisp.dhis.android.core.wipe;

import org.hisp.dhis.android.core.D2;
import org.hisp.dhis.android.core.common.D2Factory;
import org.hisp.dhis.android.core.common.EventCallFactory;
import org.hisp.dhis.android.core.data.database.AbsStoreTestCase;
import org.hisp.dhis.android.core.data.database.DatabaseAssert;
import org.hisp.dhis.android.core.data.server.RealServerMother;
import org.hisp.dhis.android.core.event.EventEndpointCall;
import org.junit.Before;

import java.io.IOException;

public class WipeDBCallRealIntegrationShould extends AbsStoreTestCase {
    private D2 d2;

    @Before
    @Override
    public void setUp() throws IOException {
        super.setUp();

        d2 = D2Factory.create(RealServerMother.url, databaseAdapter());
    }

    //@Test
    public void have_empty_database_when_wipe_db_after_sync_metadata() throws Exception {
        d2.logIn("android", "Android123").call();

        d2.syncMetaData().call();

        DatabaseAssert.assertThatDatabase(databaseAdapter()).isNotEmpty();

        d2.wipeModule().wipeEverything();

        DatabaseAssert.assertThatDatabase(databaseAdapter()).isEmpty();
    }

    //@Test
    public void have_empty_database_when_wipe_db_after_sync_data() throws Exception {
        d2.logIn("android", "Android123").call();

        d2.syncMetaData().call();

        EventEndpointCall eventCall = EventCallFactory.create(d2.retrofit(), "DiszpKrYNg8", 0);

        eventCall.call();

        DatabaseAssert.assertThatDatabase(databaseAdapter()).isNotEmpty();

        d2.wipeModule().wipeEverything();

        DatabaseAssert.assertThatDatabase(databaseAdapter()).isEmpty();
    }
}

@@ -452,49 +452,186 @@
 org.
-junit.Before;%0A%0Aimport java.io.IOException
+hisp.dhis.android.core.trackedentity.TrackedEntityInstanceStoreImpl;%0Aimport org.junit.Before;%0A%0Aimport java.io.IOException;%0A%0Aimport static com.google.common.truth.Truth.assertThat
 ;%0A%0Ap
@@ -1014,39 +1014,64 @@
 2.logIn(
-%22android%22, %22Android123%22
+RealServerMother.user, RealServerMother.password
 ).call()
@@ -1425,31 +1425,56 @@
 gIn(
-%22android%22, %22Android123%22
+RealServerMother.user, RealServerMother.password
 ).ca
@@ -1836,10 +1836,1179 @@
 ;%0A    %7D%0A
-%7D
 %0A
+    //@Test%0A    public void do_not_have_metadata_when_wipe_metadata_after_sync_metadata() throws Exception %7B%0A        d2.logIn(RealServerMother.user, RealServerMother.password).call();%0A%0A        d2.syncMetaData().call();%0A%0A        DatabaseAssert.assertThatDatabase(databaseAdapter()).isNotEmpty();%0A%0A        d2.wipeModule().wipeMetadata();%0A%0A        DatabaseAssert.assertThatDatabase(databaseAdapter()).isEmpty();%0A    %7D%0A%0A    //@Test%0A    public void do_not_have_data_when_wipe_data_after_sync() throws Exception %7B%0A        d2.logIn(RealServerMother.user, RealServerMother.password).call();%0A%0A        d2.syncMetaData().call();%0A%0A        d2.downloadTrackedEntityInstances(5, false).call();%0A%0A        TrackedEntityInstanceStoreImpl trackedEntityInstanceStore =%0A                new TrackedEntityInstanceStoreImpl(databaseAdapter());%0A%0A        boolean hasTrackedEntities = trackedEntityInstanceStore.queryAll().values().iterator().hasNext();%0A%0A        assertThat(hasTrackedEntities).isTrue();%0A%0A        d2.wipeModule().wipeData();%0A%0A        hasTrackedEntities = trackedEntityInstanceStore.queryAll().values().iterator().hasNext();%0A%0A        assertThat(hasTrackedEntities).isFalse();%0A    %7D%0A%7D

add tests on WipeDBCallRealIntegrationShould