### Question:
DefaultIconSetManager implements IconSetManager { @Override public List<String> getIconSetNames() throws IconException { try { String xwql = "SELECT obj.name FROM Document doc, doc.object(IconThemesCode.IconThemeClass) obj " + "ORDER BY obj.name"; Query query = queryManager.createQuery(xwql, Query.XWQL); return query.execute(); } catch (QueryException e) { throw new IconException("Failed to get the name of all icon sets.", e); } }  @Override IconSet getCurrentIconSet(); @Override IconSet getDefaultIconSet(); @Override IconSet getIconSet(String name); @Override List<String> getIconSetNames();  }### Answer:
@Test public void getIconSetNames() throws Exception { Query query = mock(Query.class); when(queryManager.createQuery("SELECT obj.name FROM Document doc, doc.object(IconThemesCode.IconThemeClass) obj" + " ORDER BY obj.name", Query.XWQL)).thenReturn(query); List<String> results = new ArrayList<>(); when(query.<String>execute()).thenReturn(results); assertTrue(results == mocker.getComponentUnderTest().getIconSetNames()); }
@Test public void getIconSetNamesWhenException() throws Exception { QueryException exception = new QueryException("exception in the query", null, null); when(queryManager.createQuery(any(), eq(Query.XWQL))).thenThrow(exception); IconException caughtException = null; try { mocker.getComponentUnderTest().getIconSetNames(); } catch (IconException e) { caughtException = e; } assertNotNull(caughtException); assertEquals("Failed to get the name of all icon sets.", caughtException.getMessage()); assertEquals(exception, caughtException.getCause()); }