### Question:
DatabaseConsistencyCheckHelper { static void checkForConfigsSelectedMoreThanOnce() { LOG.info("Checking for more than 1 configuration of the same type being enabled."); String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY = "select c.cluster_name, cc.type_name from clusterconfig cc " + "join clusters c on cc.cluster_id=c.cluster_id " + "group by c.cluster_name, cc.type_name " + "having sum(selected) > 1"; Multimap<String, String> clusterConfigTypeMap = HashMultimap.create(); ResultSet rs = null; Statement statement = null; ensureConnection(); try { statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = statement.executeQuery(GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY); if (rs != null) { while (rs.next()) { clusterConfigTypeMap.put(rs.getString("cluster_name"), rs.getString("type_name")); } for (String clusterName : clusterConfigTypeMap.keySet()) { error("You have config(s), in cluster {}, that is(are) selected more than once in clusterconfig table: {}", clusterName ,StringUtils.join(clusterConfigTypeMap.get(clusterName), ",")); } } } catch (SQLException e) { warning("Exception occurred during check for config selected more than once procedure: ", e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { LOG.error("Exception occurred during result set closing procedure: ", e); } } if (statement != null) { try { statement.close(); } catch (SQLException e) { LOG.error("Exception occurred during statement closing procedure: ", e); } } } }  static DatabaseConsistencyCheckResult getLastCheckResult(); static void resetCheckResult(); static void setInjector(Injector injector); static void setConnection(Connection connection); static void closeConnection(); static DatabaseConsistencyCheckResult runAllDBChecks(boolean fixIssues); static void checkDBVersionCompatible(); static final String GET_CONFIGS_SELECTED_MORE_THAN_ONCE_QUERY; }### Answer:
@Test public void testCheckForConfigsSelectedMoreThanOnce() throws Exception { EasyMockSupport easyMockSupport = new EasyMockSupport(); final DBAccessor mockDBDbAccessor = easyMockSupport.createNiceMock(DBAccessor.class); final Connection mockConnection = easyMockSupport.createNiceMock(Connection.class); final ResultSet mockResultSet = easyMockSupport.createNiceMock(ResultSet.class); final Statement mockStatement = easyMockSupport.createNiceMock(Statement.class); final StackManagerFactory mockStackManagerFactory = easyMockSupport.createNiceMock(StackManagerFactory.class); final EntityManager mockEntityManager = easyMockSupport.createNiceMock(EntityManager.class); final Clusters mockClusters = easyMockSupport.createNiceMock(Clusters.class); final OsFamily mockOSFamily = easyMockSupport.createNiceMock(OsFamily.class); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(StackManagerFactory.class).toInstance(mockStackManagerFactory); bind(EntityManager.class).toInstance(mockEntityManager); bind(DBAccessor.class).toInstance(mockDBDbAccessor); bind(Clusters.class).toInstance(mockClusters); bind(OsFamily.class).toInstance(mockOSFamily); } }); expect(mockConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)).andReturn(mockStatement); expect(mockStatement.executeQuery("select c.cluster_name, cc.type_name from clusterconfig cc " + "join clusters c on cc.cluster_id=c.cluster_id " + "group by c.cluster_name, cc.type_name " + "having sum(selected) > 1")).andReturn(mockResultSet); DatabaseConsistencyCheckHelper.setInjector(mockInjector); DatabaseConsistencyCheckHelper.setConnection(mockConnection); easyMockSupport.replayAll(); DatabaseConsistencyCheckHelper.checkForConfigsSelectedMoreThanOnce(); easyMockSupport.verifyAll(); }