@Test(expected = NullPointerException.class) public void testSetUpperLayerRejectsNull() { Layer upperLayer = mock(Layer.class); AbstractLayer layerToTest = new AbstractLayer() { }; layerToTest.setUpperLayer(upperLayer); layerToTest.setUpperLayer(null); }
@Override public final void setUpperLayer(final Layer layer) { if (upperLayer != layer) { if (upperLayer != null) { upperLayer.setLowerLayer(null); } upperLayer = layer; upperLayer.setLowerLayer(this); } }
AbstractLayer implements Layer { @Override public final void setUpperLayer(final Layer layer) { if (upperLayer != layer) { if (upperLayer != null) { upperLayer.setLowerLayer(null); } upperLayer = layer; upperLayer.setLowerLayer(this); } } }
AbstractLayer implements Layer { @Override public final void setUpperLayer(final Layer layer) { if (upperLayer != layer) { if (upperLayer != null) { upperLayer.setLowerLayer(null); } upperLayer = layer; upperLayer.setLowerLayer(this); } }  }
AbstractLayer implements Layer { @Override public final void setUpperLayer(final Layer layer) { if (upperLayer != layer) { if (upperLayer != null) { upperLayer.setLowerLayer(null); } upperLayer = layer; upperLayer.setLowerLayer(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(); }
AbstractLayer implements Layer { @Override public final void setUpperLayer(final Layer layer) { if (upperLayer != layer) { if (upperLayer != null) { upperLayer.setLowerLayer(null); } upperLayer = layer; upperLayer.setLowerLayer(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();  }