use of mondrian.xmla.DataSourcesConfig.Catalogs in project pentaho-platform by pentaho.
the class MondrianCatalogHelperTest method testLoadCatalogsIntoCache.
@Test
public void testLoadCatalogsIntoCache() {
DataSourcesConfig.DataSources dsList = new DataSourcesConfig.DataSources();
dsList.dataSources = new DataSource[1];
DataSource ds = new DataSource();
dsList.dataSources[0] = ds;
ds.catalogs = new Catalogs();
ds.catalogs.catalogs = new Catalog[1];
Catalog ct = new Catalog();
ct.definition = DEFINITION;
ds.catalogs.catalogs[0] = ct;
MockUp<ICacheManager> cmMock = new MockUp<ICacheManager>() {
Object cacheValue;
@Mock
public boolean cacheEnabled(String s) {
return true;
}
@Mock
public Object getFromRegionCache(String s, Object obj) {
return cacheValue;
}
@Mock
public void putInRegionCache(String s, Object obj, Object obj1) {
cacheValue = obj1;
}
};
final ICacheManager cm = cmMock.getMockInstance();
new NonStrictExpectations(PentahoSystem.class) {
{
PentahoSystem.getCacheManager(null);
result = cm;
}
};
mch.loadCatalogsIntoCache(dsList, null);
Object cacheValue = cm.getFromRegionCache(null, null);
Assert.assertTrue(Map.class.isInstance(cacheValue));
Map<?, ?> map = (Map<?, ?>) cacheValue;
for (Object item : map.values()) {
Assert.assertTrue(MondrianCatalog.class.isInstance(item));
MondrianCatalog catalog = (MondrianCatalog) item;
Assert.assertEquals(DEFINITION, catalog.getDefinition());
}
}
Aggregations