### Question:
CoapServer { public void setObservationHandler(ObservationHandler observationHandler) { this.observationHandler = observationHandler; LOGGER.trace("Observation handler set [{}]", observationHandler); } CoapServer(CoapMessaging coapMessaging); static CoapServerBuilder.CoapServerBuilderForUdp builder(); static CoapServerBuilder.CoapServerBuilderForTcp builderForTcp(); synchronized CoapServer start(); final synchronized void stop(); boolean isRunning(); void addRequestHandler(String uri, CoapHandler coapHandler); void removeRequestHandler(CoapHandler requestHandler); InetSocketAddress getLocalSocketAddress(); final CompletableFuture<CoapPacket> makeRequest(CoapPacket requestPacket); final CompletableFuture<CoapPacket> makeRequest(CoapPacket requestPacket, final TransportContext transContext); final void makeRequest(CoapPacket packet, Callback<CoapPacket> callback); void makeRequest(final CoapPacket packet, final Callback<CoapPacket> callback, final TransportContext transContext); void sendNotification(final CoapPacket notifPacket, final Callback<CoapPacket> callback, final TransportContext transContext); void ping(InetSocketAddress destination, final Callback<CoapPacket> callback); void setObservationHandler(ObservationHandler observationHandler); void setConnectHandler(Consumer<InetSocketAddress> disconnectConsumer); void useCriticalOptionTest(boolean enable); CoapHandler getResourceLinkResource(); List<LinkFormat> getResourceLinks(); void sendResponse(CoapExchange exchange); byte[] observe(String uri, InetSocketAddress destination, final Callback<CoapPacket> respCallback, byte[] token, TransportContext transportContext); byte[] observe(CoapPacket request, final Callback<CoapPacket> respCallback, TransportContext transportContext); void setObservationIDGenerator(ObservationIDGenerator observationIDGenerator); CoapMessaging getCoapMessaging();  }### Answer:
@Test public void receiveObservationCancellation_withCode() throws Exception { ObservationHandler observationHandler = mock(ObservationHandler.class); server.setObservationHandler(observationHandler); server.coapRequestHandler.handleObservation(newCoapPacket(LOCAL_5683).con(Code.C404_NOT_FOUND).obs(0).token(33).payload("A").mid(2).build(), TransportContext.NULL); verify(observationHandler).callException(isA(ObservationTerminatedException.class)); assertSendResponse(newCoapPacket(LOCAL_5683).emptyAck(2)); }