Commit da5f4efd authored by Mathieu Féry (Mathius)'s avatar Mathieu Féry (Mathius)
Browse files

Add removeAllFavs method

parent 6b7aa5af
Pipeline #23270 failed with stages
in 3 minutes and 17 seconds
package fr.iutnantes.miar.dndgenerator.api.dnd.models;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import android.content.Context;
import java.util.ArrayList;
import java.util.List;
import fr.iutnantes.miar.dndgenerator.api.dnd.DnDSheet;
import fr.iutnantes.miar.dndgenerator.api.dnd.DnDSheetTest;
import fr.iutnantes.miar.dndgenerator.api.tenor.GIFArtifact;
import fr.iutnantes.miar.dndgenerator.api.tenor.GIFObject;
import fr.iutnantes.miar.dndgenerator.api.tenor.GIFObjectTest;
import fr.iutnantes.miar.dndgenerator.api.tenor.TenorArgs;
import fr.iutnantes.miar.dndgenerator.api.tenor.models.GIFArtifactDB;
@RunWith(AndroidJUnit4.class)
public class DnDSheetDBTest {
......@@ -31,9 +23,7 @@ public class DnDSheetDBTest {
public int dbVersion = DnDSheetDB.DATABASE_VERSION + 1;
public void dropDBs() {
new DnDSheetDB(ctx, dbVersion).onClear();
new GIFArtifactDB(ctx, dbVersion).onClear();
new DnDSavesDB(ctx, dbVersion).onClear();
DnDSheet.removeAllFavs(ctx, dbVersion);
}
@Test
......
......@@ -20,9 +20,11 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import fr.iutnantes.miar.dndgenerator.api.dnd.models.DnDSavesDB;
import fr.iutnantes.miar.dndgenerator.api.dnd.models.DnDSheetDB;
import fr.iutnantes.miar.dndgenerator.api.tenor.GIFObject;
import fr.iutnantes.miar.dndgenerator.api.tenor.TenorArgs;
import fr.iutnantes.miar.dndgenerator.api.tenor.models.GIFArtifactDB;
/**
* DnDSheet is a class that represents a D&D character sheet.
......@@ -176,6 +178,16 @@ public class DnDSheet implements Serializable {
return getFavs(ctx, DnDSheetDB.DATABASE_VERSION);
}
public static void removeAllFavs(@NonNull Context ctx, int dbVersion) {
new DnDSheetDB(ctx, dbVersion).onClear();
new GIFArtifactDB(ctx, dbVersion).onClear();
new DnDSavesDB(ctx, dbVersion).onClear();
}
public static void removeAllFavs(@NonNull Context ctx) {
removeAllFavs(ctx, DnDSheetDB.DATABASE_VERSION);
}
/**
* For write sheet.
* @return toString
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment