@Test
  public void shouldUpdateRecord() throws Exception {
    RecordPayload recordPayload = RecordPayload.instanceOf(10);

    when(mockService.get(argThat(isString(TEST_ID)))).thenReturn(Record.instanceOf(10));
    when(mockService.update(argThat(isRecord(TEST_ID, 10)))).thenReturn(Record.instanceOf(10));

    Response response = recordResource.updateRecord(TEST_ID, recordPayload);

    assertThat(response.getStatus(), is(HttpStatus.NOT_MODIFIED.value()));
  }
  @Test
  public void shouldReturnNotFoundWhenDeletingARecordThatDoesNotExist() {

    when(mockService.get(argThat(isString(TEST_ID)))).thenReturn(null);

    Response response = recordResource.deleteRecord(TEST_ID);

    assertThat(response.getStatus(), is(HttpStatus.NOT_FOUND.value()));
  }
  @Test
  public void shouldDeleteRecord() throws Exception {

    when(mockService.get(argThat(isString(TEST_ID)))).thenReturn(Record.instanceOf(10));

    Response response = recordResource.deleteRecord(TEST_ID);

    verify(mockService, times(1)).delete(argThat(isString(TEST_ID)));

    assertThat(response.getStatus(), is(HttpStatus.OK.value()));
  }
  @Test
  public void shouldReturnNotFoundWhenGettingARecordThatDoesNotExist() {

    when(mockService.get(argThat(isString(TEST_ID)))).thenReturn(null);

    Response response = recordResource.getRecord(TEST_ID);

    RecordPayload recordPayload = (RecordPayload) response.getEntity();

    assertThat(response.getStatus(), is(HttpStatus.NOT_FOUND.value()));

    assertThat(recordPayload, is(nullValue()));
  }
  @Test
  public void shouldGetRecord() throws Exception {

    Record record = Record.instanceOf(10);

    when(mockService.get(argThat(isString(TEST_ID)))).thenReturn(record);

    Response response = recordResource.getRecord(TEST_ID);

    assertThat(response.getStatus(), is(HttpStatus.OK.value()));

    RecordPayload recordPayload = (RecordPayload) response.getEntity();

    assertThat(recordPayload.getNumber(), is(10));
  }
  @Test
  public void shouldGetAll() throws Exception {

    List<Record> records = new ArrayList<Record>();

    when(mockService.getAll()).thenReturn(records);

    Response response = recordResource.getAll();

    assertThat(response.getStatus(), is(HttpStatus.OK.value()));

    List<RecordPayload> list = (List<RecordPayload>) response.getEntity();

    assertThat(list.size(), is(0));
  }
  @Test
  public void shouldCreateRecord() throws Exception {

    RecordPayload recordPayload = RecordPayload.instanceOf(7);

    when(mockService.create(argThat(isRecord(null, 7)))).thenReturn(TEST_ID);
    when(mockUriInfo.getAbsolutePathBuilder())
        .thenReturn(UriBuilder.fromPath("http://localhost:8080/services/webapi/myresource"));

    Response response = recordResource.createRecord(recordPayload);

    assertThat(
        response.getLocation().toString(),
        is("http://localhost:8080/services/webapi/myresource/a02"));
    assertThat(response.getStatus(), is(HttpStatus.CREATED.value()));
  }