### Question:
ServiceContext { public synchronized boolean deleteInstance(Instance instance) { if (instance == null) return false; List<Instance> instances = service.getInstances(); if (instances == null) return false; return instances.remove(instance); } 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 testDeleteInstance() { ServiceContext context = new ServiceContext(_discoveryConfig); Instance instance1 = Instances.newInstance(_serviceId); Assert.assertTrue(context.addInstance(instance1)); Assert.assertEquals(1, context.newService().getInstances().size()); Assert.assertTrue(context.deleteInstance(instance1)); Assert.assertEquals(0, context.newService().getInstances().size()); Assert.assertFalse(context.deleteInstance(instance1)); }