### Question:
CassandraInstanceServiceImpl implements CassandraInstanceService { @Override public ImmutableSet<CassandraInstance> findAll(String ring) { try { return dao.findAll(ring); } catch (BackingStoreException e) { throw new ServiceUnavailableException(e); } } @Inject  CassandraInstanceServiceImpl(CassandraInstanceDao dao); @Override ImmutableSet<CassandraInstance> findAll(String ring); @Override @Nullable CassandraInstance findById(String ring, int id); @Override void save(String ring, CassandraInstance instance); @Override void delete(String ring, CassandraInstance instance);  }### Answer:
@Test public void findAll() throws Exception { CassandraInstance instance1 = createMock(CassandraInstance.class); CassandraInstance instance2 = createMock(CassandraInstance.class); CassandraInstance instance3 = createMock(CassandraInstance.class); ImmutableSet<CassandraInstance> instances = ImmutableSet.of(instance1, instance2, instance3); expect(dao.findAll(RING_NAME)).andReturn(instances); replayAll(); assertEquals(instances, service.findAll(RING_NAME)); }
@Test(expected = ServiceUnavailableException.class) public void findAll_backingStoreException() throws Exception { expect(dao.findAll(RING_NAME)).andThrow(new BackingStoreException()); replayAll(); service.findAll(RING_NAME); }