ProxyURLToContextMapping { public void register(URL proxyUrl, Class<?> testClass, OperationalContext context) { if (urlToContext.get(proxyUrl) != null) { throw new IllegalStateException("The OperatiocalContext was already set for URL: " + proxyUrl); } urlToContext.put(proxyUrl, context); Set<URL> urls = testClassToUrls.get(testClass); if (urls == null) { urls = new LinkedHashSet<URL>(); testClassToUrls.put(testClass, urls); } urls.add(proxyUrl); }  void register(URL proxyUrl, Class<?> testClass, OperationalContext context); OperationalContext get(URL proxyUrl); void unregister(Class<?> testClass); boolean isRegistered(URL proxyUrl);  }
@Test(expected = IllegalStateException.class) public void when_another_classes_for_same_url_are_registered_then_mapping_should_fail_to_register() { mapping.register(url, TestingClass.class, context); mapping.register(url, AnotherClass.class, context); }
@Test public void when_more_urls_are_registered_to_one_class_then_mapping_should_carry_them_all() { mapping.register(url, TestingClass.class, context); mapping.register(anotherUrl, TestingClass.class, context); }