### Question:
LearningBehavior implements ILearningBehavior<ACTION> { @Override public void handleNewExperience(Observation observation, ACTION action, double reward, boolean isTerminal) { experienceHandler.addExperience(observation, action, reward, isTerminal); if(experienceHandler.isTrainingBatchReady()) { handleBatch(); } }  @Override void handleEpisodeStart(); @Override void handleNewExperience(Observation observation, ACTION action, double reward, boolean isTerminal); @Override void handleEpisodeEnd(Observation finalObservation); void notifyBeforeStep();  }### Answer:
@Test public void when_callingHandleNewExperience_expect_experienceHandlerAddExperienceCalled() { INDArray observationData = Nd4j.rand(1, 1); when(experienceHandlerMock.isTrainingBatchReady()).thenReturn(false); sut.handleNewExperience(new Observation(observationData), 1, 2.0, false); ArgumentCaptor<Observation> observationCaptor = ArgumentCaptor.forClass(Observation.class); ArgumentCaptor<Integer> actionCaptor = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<Double> rewardCaptor = ArgumentCaptor.forClass(Double.class); ArgumentCaptor<Boolean> isTerminatedCaptor = ArgumentCaptor.forClass(Boolean.class); verify(experienceHandlerMock, times(1)).addExperience(observationCaptor.capture(), actionCaptor.capture(), rewardCaptor.capture(), isTerminatedCaptor.capture()); assertEquals(observationData.getDouble(0, 0), observationCaptor.getValue().getData().getDouble(0, 0), 0.00001); assertEquals(1, (int)actionCaptor.getValue()); assertEquals(2.0, (double)rewardCaptor.getValue(), 0.00001); assertFalse(isTerminatedCaptor.getValue()); verify(updateRuleMock, never()).update(any(List.class)); }
@Test public void when_callingHandleNewExperienceAndTrainingBatchIsReady_expect_updateRuleUpdateWithTrainingBatch() { INDArray observationData = Nd4j.rand(1, 1); when(experienceHandlerMock.isTrainingBatchReady()).thenReturn(true); List<Object> trainingBatch = new ArrayList<Object>(); when(experienceHandlerMock.generateTrainingBatch()).thenReturn(trainingBatch); sut.handleNewExperience(new Observation(observationData), 1, 2.0, false); verify(updateRuleMock, times(1)).update(trainingBatch); }