Search in sources :

Example 1 with SimpleKeyInfoRepo

use of com.rdbcache.repositories.SimpleKeyInfoRepo in project rdbcache by rdbcache.

the class RequestTest method setUp.

@Before
public void setUp() throws Exception {
    InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("test-keyinfos.json");
    assertNotNull(inputStream);
    String text = null;
    try (final Reader reader = new InputStreamReader(inputStream)) {
        text = CharStreams.toString(reader);
    }
    assertNotNull(text);
    Map<String, Object> map = Utils.toMap(text);
    assertNotNull(map);
    PowerMockito.mockStatic(AppCtx.class);
    keyInfoRepo = new SimpleKeyInfoRepo(map);
    BDDMockito.when(AppCtx.getKeyInfoRepo()).thenReturn(keyInfoRepo);
    DbaseOps dbaseOps = mock(DbaseOps.class, Mockito.RETURNS_DEEP_STUBS);
    assertNotNull(dbaseOps);
    Mockito.when(dbaseOps.getTableList(any(Context.class))).thenReturn(Arrays.asList("user_table", "tb1"));
    BDDMockito.when(AppCtx.getDbaseOps()).thenReturn(dbaseOps);
    LocalCache localCache = new LocalCache();
    localCache.init();
    localCache.handleEvent(null);
    BDDMockito.when(AppCtx.getLocalCache()).thenReturn(localCache);
}
Also used : MockServletContext(org.springframework.mock.web.MockServletContext) DbaseOps(com.rdbcache.services.DbaseOps) SimpleKeyInfoRepo(com.rdbcache.repositories.SimpleKeyInfoRepo) InputStreamReader(java.io.InputStreamReader) LocalCache(com.rdbcache.services.LocalCache) InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Before(org.junit.Before)

Aggregations

SimpleKeyInfoRepo (com.rdbcache.repositories.SimpleKeyInfoRepo)1 DbaseOps (com.rdbcache.services.DbaseOps)1 LocalCache (com.rdbcache.services.LocalCache)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 Before (org.junit.Before)1 MockServletContext (org.springframework.mock.web.MockServletContext)1