ServiceContext { public static ServiceContext of(Map<Class<?>, Object> services) { ArgumentChecker.noNulls(services, "services"); return new ServiceContext(ImmutableClassToInstanceMap.copyOf(services)); } private  ServiceContext(ImmutableClassToInstanceMap<Object> services); static ServiceContext of(Map<Class<?>, Object> services); static ServiceContext of(Class<T> clazz, T service); boolean contains(Class<?> serviceClass); T get(Class<T> serviceClass); ServiceContext with(Map<Class<?>, Object> services); ServiceContext with(Class<?> clazz, Object service); @Override String toString();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCreateServiceHandlesNullClass() { ServiceContext.of(null, new Object()); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCreateServiceHandlesNullObject() { ServiceContext.of(ConfigSource.class, null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCreateServiceWithMapHandlesNullClass() { ServiceContext.of(null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCreateServiceWithMapHandlesNullKeys() { Map<Class<?>, Object> services = new HashMap<>(); services.put(ConfigSource.class, null); ServiceContext.of(services); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testCreateServiceWithMapHandlesNullValues() { Map<Class<?>, Object> services = new HashMap<>(); services.put(null, new Object()); ServiceContext.of(services); }
@Test(expectedExceptions = ClassCastException.class) public void testCreateServiceWithIncorrectTypeIsDetected() { Map<Class<?>, Object> services = new HashMap<>(); services.put(ConfigSource.class, MOCK_SECURITY_SOURCE); ServiceContext.of(services); }