### Question:
UserStore extends AbstractStore<User> { public Users getUsers() throws StoreException { Users users = new Users(); users.setUsers(listAll()); return users; } UserStore(final ConnectionProvider dbConnectionFactory, final PasswordHashService passwordService); Users getUsers(); User getUser(final String id); User putUser(final User user); static final String SQL_ID; static final String SQL_DOMAIN_ID; static final String SQL_NAME; static final String SQL_EMAIL; static final String SQL_PASSWORD; static final String SQL_DESCR; static final String SQL_ENABLED; static final String SQL_SALT; }### Answer:
@Test public void getUsersTest() throws SQLException, Exception { String[] tableTypes = { "TABLE" }; Mockito.when(connectionMock.isClosed()).thenReturn(false); DatabaseMetaData dbmMock = mock(DatabaseMetaData.class); Mockito.when(connectionMock.getMetaData()).thenReturn(dbmMock); ResultSet rsUserMock = mock(ResultSet.class); Mockito.when(dbmMock.getTables(null, null, "USERS", tableTypes)).thenReturn(rsUserMock); Mockito.when(rsUserMock.next()).thenReturn(true); Statement stmtMock = mock(Statement.class); Mockito.when(connectionMock.createStatement()).thenReturn(stmtMock); ResultSet rsMock = getMockedResultSet(); Mockito.when(stmtMock.executeQuery(anyString())).thenReturn(rsMock); Users users = userStoreUnderTest.getUsers(); assertTrue(users.getUsers().size() == 1); verify(stmtMock).close(); }