Search in sources :

Example 1 with MetaBuilder

use of org.openmuc.framework.datalogger.sql.MetaBuilder in project OpenMUC by isc-konstanz.

the class TableSetupTest method setupInitializer.

@BeforeEach
void setupInitializer() throws SQLException {
    accessMock = mock(DbAccess.class);
    channelList = new ArrayList<>();
    channelList.add(getMockedChannel("gridPower"));
    channelList.add(getMockedChannel("pvPower"));
    ResultSet resultMocked = mock(ResultSet.class);
    ResultSetMetaData resultMetaMock = mock(ResultSetMetaData.class);
    when(resultMetaMock.getColumnCount()).thenReturn(0);
    when(resultMocked.getMetaData()).thenReturn(resultMetaMock);
    when(accessMock.executeQuery(any())).thenReturn(resultMocked);
    when(accessMock.getColumnLength(anyList(), anyString())).thenReturn(Collections.nCopies(20, 20));
    PropertyHandler propHandlerMock = mock(PropertyHandler.class);
    when(propHandlerMock.getString(Settings.URL)).thenReturn("jdbc:h2");
    PropertyHandlerProvider.getInstance().setPropertyHandler(propHandlerMock);
    tableSetup = new TableSetup(channelList, accessMock);
    metaBuilder = new MetaBuilder(channelList, accessMock);
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) MetaBuilder(org.openmuc.framework.datalogger.sql.MetaBuilder) PropertyHandler(org.openmuc.framework.lib.osgi.config.PropertyHandler) ResultSet(java.sql.ResultSet) TableSetup(org.openmuc.framework.datalogger.sql.TableSetup) DbAccess(org.openmuc.framework.datalogger.sql.DbAccess) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 DbAccess (org.openmuc.framework.datalogger.sql.DbAccess)1 MetaBuilder (org.openmuc.framework.datalogger.sql.MetaBuilder)1 TableSetup (org.openmuc.framework.datalogger.sql.TableSetup)1 PropertyHandler (org.openmuc.framework.lib.osgi.config.PropertyHandler)1