@Test
public void failWhenSyncRequest() throws Exception {

    doThrow(new CoapException("")).when(coapTransport).sendPacket(any(), any(), any());
    assertThatThrownBy(() -> client.resource("/test").sync().get()).isExactlyInstanceOf(CoapException.class);
    doThrow(new IOException(new CoapException(""))).when(coapTransport).sendPacket(any(), any(), any());
    assertThatThrownBy(() -> client.resource("/test").sync().post()).isExactlyInstanceOf(CoapException.class);
    doThrow(new IOException()).when(coapTransport).sendPacket(any(), any(), any());
    assertThatThrownBy(() -> client.resource("/test").sync().put()).hasCauseExactlyInstanceOf(IOException.class);
    doThrow(new CoapException("")).when(coapTransport).sendPacket(any(), any(), any());
    assertThatThrownBy(() -> client.resource("/test").sync().delete()).isExactlyInstanceOf(CoapException.class);
}