AbstractLayer implements Layer { @Override public final void setLowerLayer(final Layer layer) { if (lowerLayer != layer) { if (lowerLayer != null) { lowerLayer.setUpperLayer(null); } lowerLayer = layer; lowerLayer.setUpperLayer(this); } }  @Override void sendRequest(final Exchange exchange, final Request request); @Override void sendResponse(final Exchange exchange, final Response response); @Override void sendEmptyMessage(final Exchange exchange, final EmptyMessage message); @Override void receiveRequest(final Exchange exchange, final Request request); @Override void receiveResponse(final Exchange exchange, final Response response); @Override void receiveEmptyMessage(final Exchange exchange, final EmptyMessage message); @Override final void setLowerLayer(final Layer layer); @Override final void setUpperLayer(final Layer layer); @Override final void setExecutors(ScheduledExecutorService mainExecutor, ScheduledExecutorService secondaryExecutor); final void reject(final Exchange exchange, final Message message); @Override void start(); @Override void destroy();  }
@Test(expected = NullPointerException.class) public void testSetLowerLayerRejectsNull() { Layer lowerLayer = mock(Layer.class); AbstractLayer layerToTest = new AbstractLayer() { }; layerToTest.setLowerLayer(lowerLayer); layerToTest.setLowerLayer(null); }