Home | History | Annotate | Download | only in test
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package androidx.room.integration.testapp.test;
     18 
     19 import android.content.Context;
     20 import android.support.test.InstrumentationRegistry;
     21 
     22 import androidx.room.Room;
     23 import androidx.room.integration.testapp.TestDatabase;
     24 import androidx.room.integration.testapp.dao.FunnyNamedDao;
     25 import androidx.room.integration.testapp.dao.PetCoupleDao;
     26 import androidx.room.integration.testapp.dao.PetDao;
     27 import androidx.room.integration.testapp.dao.RawDao;
     28 import androidx.room.integration.testapp.dao.SchoolDao;
     29 import androidx.room.integration.testapp.dao.SpecificDogDao;
     30 import androidx.room.integration.testapp.dao.ToyDao;
     31 import androidx.room.integration.testapp.dao.UserDao;
     32 import androidx.room.integration.testapp.dao.UserPetDao;
     33 import androidx.room.integration.testapp.dao.WithClauseDao;
     34 
     35 import org.junit.Before;
     36 
     37 @SuppressWarnings("WeakerAccess")
     38 public abstract class TestDatabaseTest {
     39     protected TestDatabase mDatabase;
     40     protected UserDao mUserDao;
     41     protected PetDao mPetDao;
     42     protected UserPetDao mUserPetDao;
     43     protected SchoolDao mSchoolDao;
     44     protected PetCoupleDao mPetCoupleDao;
     45     protected ToyDao mToyDao;
     46     protected SpecificDogDao mSpecificDogDao;
     47     protected WithClauseDao mWithClauseDao;
     48     protected FunnyNamedDao mFunnyNamedDao;
     49     protected RawDao mRawDao;
     50 
     51     @Before
     52     public void createDb() {
     53         Context context = InstrumentationRegistry.getTargetContext();
     54         mDatabase = Room.inMemoryDatabaseBuilder(context, TestDatabase.class).build();
     55         mUserDao = mDatabase.getUserDao();
     56         mPetDao = mDatabase.getPetDao();
     57         mUserPetDao = mDatabase.getUserPetDao();
     58         mSchoolDao = mDatabase.getSchoolDao();
     59         mPetCoupleDao = mDatabase.getPetCoupleDao();
     60         mToyDao = mDatabase.getToyDao();
     61         mSpecificDogDao = mDatabase.getSpecificDogDao();
     62         mWithClauseDao = mDatabase.getWithClauseDao();
     63         mFunnyNamedDao = mDatabase.getFunnyNamedDao();
     64         mRawDao = mDatabase.getRawDao();
     65     }
     66 }
     67