@Test public void findById() throws Exception { CassandraInstance instance = createMock(CassandraInstance.class); expect(service.findById(RING_NAME, CASSANDRA_ID)).andReturn(instance); replayAll(); assertEquals(instance, resource.findById(CASSANDRA_ID)); }
@Test public void deleteInstance() throws Exception { CassandraInstance instance = createMock(CassandraInstance.class); expect(service.findById(RING_NAME, CASSANDRA_ID)).andReturn(instance); service.delete(RING_NAME, instance); replayAll(); Response response = resource.deleteInstance(CASSANDRA_ID); assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus()); }
@Test public void findById_notFound() throws Exception { expect(service.findById(RING_NAME, CASSANDRA_ID)).andReturn(null); replayAll(); try { resource.findById(CASSANDRA_ID); fail("Expected NotFoundException"); } catch (NotFoundException e) { assertEquals(Status.NOT_FOUND.getStatusCode(), e.getResponse().getStatus()); assertEquals("No instance found with id: " + CASSANDRA_ID, e.getResponse().getEntity()); } }