### Question:
WebtopNamingSiteUtils { public Set<URL> getSiteNodeURLs(Session session) { Set<URL> urls = new HashSet<URL>(); for (String node : getSiteNodes(session)) { try { URL url = new URL(query.getServerFromID(node)); urls.add(url); } catch (MalformedURLException e) { String err = "WebtopNaming returned invalid URL"; debug.error(err, e); throw new IllegalStateException(err, e); } catch (ServerEntryNotFoundException e) { debug.error("Server not found.", e); continue; } } return urls; } @Inject  WebtopNamingSiteUtils(@Named(SessionConstants.SESSION_DEBUG) Debug debug, WebtopNamingQuery query); Set<String> getSiteNodes(Session session); Set<URL> getSiteNodeURLs(Session session);  }### Answer:
@Test public void shouldReturnURLsForServersInSite() throws ServerEntryNotFoundException { String serverID = "SERVER"; given(mockSessionID.getSessionServerID()).willReturn(serverID); given(mockQuery.getSiteID(eq(serverID))).willReturn(null); given(mockQuery.getServerFromID(anyString())).willReturn("http: Set<URL> result = utils.getSiteNodeURLs(mockSession); assertThat(result).hasSize(1); }
@Test (expectedExceptions = IllegalStateException.class) public void shouldThrowRuntimeExceptionForInvalidURLFormat() throws ServerEntryNotFoundException { String serverID = "SERVER"; given(mockSessionID.getSessionServerID()).willReturn(serverID); given(mockQuery.getSiteID(eq(serverID))).willReturn(null); given(mockQuery.getServerFromID(anyString())).willReturn("badgerbadger..."); utils.getSiteNodeURLs(mockSession); }