### Question:
ServiceContext { public synchronized boolean isAvailable() { Service service = this.service; return service != null && !CollectionValues.isNullOrEmpty(service.getInstances()); } ServiceContext(DiscoveryConfig discoveryConfig); DiscoveryConfig getDiscoveryConfig(); synchronized Service newService(); synchronized void setService(Service service); synchronized boolean deleteInstance(Instance instance); synchronized boolean updateInstance(Instance instance); synchronized boolean addInstance(Instance instance); synchronized boolean isAvailable(); synchronized Set<ServiceChangeListener> getListeners(); synchronized void addListener(final ServiceChangeListener listener); ServiceChangeEvent newServiceChangeEvent(final String changeType); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object other);  }### Answer:
@Test public void testIsAvailable() { ServiceContext context = new ServiceContext(_discoveryConfig); Assert.assertFalse(context.isAvailable()); Instance instance = Instances.newInstance(_serviceId); Assert.assertTrue(context.addInstance(instance)); Assert.assertEquals(1, context.newService().getInstances().size()); Assert.assertTrue(context.isAvailable()); Assert.assertTrue(context.deleteInstance(instance)); Assert.assertFalse(context.isAvailable()); }