### Question:
CoapServer { public void sendNotification(final CoapPacket notifPacket, final Callback<CoapPacket> callback, final TransportContext transContext) { if (notifPacket.headers().getObserve() == null) { throw new IllegalArgumentException("Notification packet should have observation header set"); } if (notifPacket.getToken() == null || notifPacket.getToken().length == 0) { throw new IllegalArgumentException("Notification packet should have non-empty token"); } if (notifPacket.getCode() != Code.C205_CONTENT) { throw new IllegalArgumentException("Notification packet should have 205_CONTENT code"); } makeRequest(notifPacket, callback, transContext); } 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 failToSendNotificationWithout_missingHeaders() { assertThatThrownBy(() -> server.sendNotification(newCoapPacket(LOCAL_5683).token(11).ack(Code.C205_CONTENT).build(), mock(Callback.class), TransportContext.NULL) ).isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> server.sendNotification(newCoapPacket(LOCAL_5683).obs(2).ack(Code.C205_CONTENT).build(), mock(Callback.class), TransportContext.NULL) ).isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> server.sendNotification(newCoapPacket(LOCAL_5683).token(321).obs(2).ack(Code.C400_BAD_REQUEST).build(), mock(Callback.class), TransportContext.NULL) ).isInstanceOf(IllegalArgumentException.class); }