public void userCreatedStagingTable() throws SQLException { this.state.setProp(ConfigurationKeys.WRITER_STAGING_TABLE, STAGING_TABLE); when(this.commands.isEmpty(DB, STAGING_TABLE)).thenReturn(Boolean.TRUE); this.initializer.initialize(); Assert.assertEquals(STAGING_TABLE, this.workUnit.getProp(ConfigurationKeys.WRITER_STAGING_TABLE)); verify(this.commands, never()).createTableStructure(anyString(), anyString(), anyString()); verify(this.commands, never()).truncate(anyString(), anyString()); verify(this.commands, never()).drop(anyString(), anyString()); }
public void initializeWithCreatingStagingTable() throws SQLException { when(this.commands.isEmpty(DB, STAGING_TABLE)).thenReturn(Boolean.TRUE); DatabaseMetaData metadata = mock(DatabaseMetaData.class); when(this.conn.getMetaData()).thenReturn(metadata); ResultSet rs = mock(ResultSet.class); when(metadata.getTables(anyString(), anyString(), anyString(), any(String[].class))).thenReturn(rs); when(rs.next()).thenReturn(Boolean.FALSE); this.initializer.initialize(); Assert.assertTrue(!StringUtils.isEmpty(this.workUnit.getProp(ConfigurationKeys.WRITER_STAGING_TABLE))); InOrder inOrder = inOrder(this.commands); inOrder.verify(this.commands, times(1)).createTableStructure(anyString(), anyString(), anyString()); inOrder.verify(this.commands, times(1)).drop(anyString(), anyString()); inOrder.verify(this.commands, times(1)).createTableStructure(anyString(), anyString(), anyString()); this.initializer.close(); inOrder.verify(this.commands, times(1)).drop(anyString(), anyString()); inOrder.verify(this.commands, never()).truncate(anyString(), anyString()); } }
public void userCreatedStagingTableTruncate() throws SQLException { this.state.setProp(ConfigurationKeys.WRITER_STAGING_TABLE, STAGING_TABLE); this.state.setProp(ConfigurationKeys.WRITER_TRUNCATE_STAGING_TABLE, Boolean.toString(true)); when(this.commands.isEmpty(DB, STAGING_TABLE)).thenReturn(Boolean.TRUE); this.initializer.initialize(); Assert.assertEquals(STAGING_TABLE, this.workUnit.getProp(ConfigurationKeys.WRITER_STAGING_TABLE)); InOrder inOrder = inOrder(this.commands); inOrder.verify(this.commands, times(1)).truncate(DB, STAGING_TABLE); this.initializer.close(); inOrder.verify(this.commands, times(1)).truncate(DB, STAGING_TABLE); verify(this.commands, never()).createTableStructure(anyString(), anyString(), anyString()); verify(this.commands, never()).drop(anyString(), anyString()); }
if (!commands.isEmpty(database, stagingTable)) { LOG.error("Staging table " + stagingTable + " is not empty. Failing."); throw new IllegalArgumentException("Staging table " + stagingTable + " should be empty.");
if (!commands.isEmpty(database, stagingTable)) { LOG.error("Staging table " + stagingTable + " is not empty. Failing."); throw new IllegalArgumentException("Staging table " + stagingTable + " should be empty.");