### Question:
MultiLayerNetworkHandler implements INetworkHandler { @Override public void applyGradient(Gradients gradients, long batchSize) { BaseNetwork.ModelCounters modelCounters = getModelCounters(); int iterationCount = modelCounters.getIterationCount(); Gradient gradient = gradients.getGradient(gradientName); model.getUpdater().update(model, gradient, iterationCount, modelCounters.getEpochCount(), (int)batchSize, LayerWorkspaceMgr.noWorkspaces()); model.params().subi(gradient.gradient()); configuration.setIterationCount(iterationCount + 1); } MultiLayerNetworkHandler(MultiLayerNetwork model, String labelName, String gradientName); @Override void notifyGradientCalculation(); @Override void notifyIterationDone(); @Override void performFit(FeaturesLabels featuresLabels); @Override void performGradientsComputation(FeaturesLabels featuresLabels); @Override void applyGradient(Gradients gradients, long batchSize); @Override INDArray[] recurrentStepOutput(Observation observation); @Override INDArray[] batchOutput(INDArray batch); @Override void resetState(); @Override INetworkHandler clone(); @Override void copyFrom(INetworkHandler from); @Override void fillGradientsResponse(Gradients gradients);  }### Answer:
@Test public void when_callingApplyGradient_expect_correctGradientAppliedAndIterationUpdated() { setup(false); Gradients gradientsMock = mock(Gradients.class); final Gradient gradient = mock(Gradient.class); INDArray gradientGradient = Nd4j.rand(1, 2); when(gradient.gradient()).thenReturn(gradientGradient); when(gradientsMock.getGradient(GRADIENT_NAME)).thenReturn(gradient); Updater updaterMock = mock(Updater.class); when(modelMock.getUpdater()).thenReturn(updaterMock); INDArray paramsMock = mock(INDArray.class); when(modelMock.params()).thenReturn(paramsMock); sut.applyGradient(gradientsMock, 345); verify(gradientsMock, times(1)).getGradient(GRADIENT_NAME); verify(updaterMock, times(1)).update(eq(modelMock), eq(gradient), eq(123), eq(234), eq(345), any()); verify(paramsMock, times(1)).subi(gradientGradient); verify(configurationMock, times(1)).setIterationCount(124); }