@Test
public void testListEntities() throws Exception {

    
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Mockito.doReturn(5).when(mockResultSet).getInt(1); // return domain id
    
    Mockito.when(mockResultSet.next())
        .thenReturn(true) // this one is for domain id
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(false);
    Mockito.when(mockResultSet.getString(1))
        .thenReturn("z-entity")
        .thenReturn("a-entity")
        .thenReturn("b-entity");
    
    List<String> entities = jdbcConn.listEntities("my-domain");
    
    // data back is sorted
    
    assertEquals(3, entities.size());
    assertEquals("a-entity", entities.get(0));
    assertEquals("b-entity", entities.get(1));
    assertEquals("z-entity", entities.get(2));
    jdbcConn.close();
}