Search in sources :

Example 1 with SimpleKeyInfoRepo

use of doitincloud.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);
    Map<String, Object> tablesMap = new LinkedHashMap<>();
    tablesMap.put("user_table", "data");
    tablesMap.put("tb1", "data");
    Mockito.when(dbaseOps.getTablesMap(any(Context.class))).thenReturn(tablesMap);
    BDDMockito.when(AppCtx.getDbaseOps()).thenReturn(dbaseOps);
    CacheOps cacheOps = new CacheOps();
    cacheOps.init();
    cacheOps.handleEvent(null);
    BDDMockito.when(AppCtx.getCacheOps()).thenReturn(cacheOps);
}
Also used : Context(doitincloud.rdbcache.supports.Context) MockServletContext(org.springframework.mock.web.MockServletContext) DbaseOps(doitincloud.rdbcache.services.DbaseOps) SimpleKeyInfoRepo(doitincloud.rdbcache.repositories.SimpleKeyInfoRepo) CacheOps(doitincloud.rdbcache.services.CacheOps) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) LinkedHashMap(java.util.LinkedHashMap) Before(org.junit.Before)

Aggregations

SimpleKeyInfoRepo (doitincloud.rdbcache.repositories.SimpleKeyInfoRepo)1 CacheOps (doitincloud.rdbcache.services.CacheOps)1 DbaseOps (doitincloud.rdbcache.services.DbaseOps)1 Context (doitincloud.rdbcache.supports.Context)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 LinkedHashMap (java.util.LinkedHashMap)1 Before (org.junit.Before)1 MockServletContext (org.springframework.mock.web.MockServletContext)1