### Question:
GeneratedOperationsModifier implements OperationConductorModifier { @Override public void modify(ExecutorContext executorContext, OperationWrapper operationWrapper, OperationConductor operationConductor) { if(!isOperationGenerator(operationWrapper.getOperation())) return; OperationGeneratorOutputDefinition outputDefinition = retrieveOutputDefinition(operationWrapper.getOperation()); if(outputDefinition.getLogOnly() != null && outputDefinition.getLogOnly()) { logger.info("Skipping operation injection (by request)."); return; } GeneratedOperationData generatedOperationData = retrieveGeneratedOperationData(operationWrapper, outputDefinition); List<Operation> generatedOperations = generatedOperationData.getOperations(); if(generatedOperations == null || generatedOperations.size() == 0) { logger.warn("No operations were generated by operation: %1$s", operationWrapper.getOperation().getName()); return; } generatedOperations.forEach(op -> { OperationWrapper opWrapper = operationWrapperFactory.create(op); opWrapper.init(executorContext, operationConductor.getJsonContextUpdater()); operationConductor.getPendingOperations().add(opWrapper); }); executorContext.getAgendaProgressReporter().adjustOperationTotalCount(generatedOperations.size()); } GeneratedOperationsModifier(ExecutorContext executorContext); @Override void modify(ExecutorContext executorContext, OperationWrapper operationWrapper, OperationConductor operationConductor); void setOperationWrapperFactory(OperationWrapperFactory operationWrapperFactory); static final String OPERATION_GENERATOR; }### Answer:
@Test public void testNonOperationGenerator() { modifier.modify(mockExecutorContext, mockOperationWrapper, mockOperationConductor); verify(mockExecutorContext, times(0)).getJsonHelper(); }
@Test public void testOperationGeneratorWithOutParams() { List<Operation> generatedOps = IntStream.range(0, 10).mapToObj(i -> new Operation()).collect(Collectors.toList()); TestGeneratedOutputObject generatedOutputObject = new TestGeneratedOutputObject(generatedOps, null); doReturn(jsonHelper.getJSONString(generatedOutputObject)).when(mockOperationWrapper).getOutputPayload(); setupOperationOutputDefinition(TestGeneratedOutputObject.OPERATIONS_PATH, null); modifier.modify(mockExecutorContext, mockOperationWrapper, mockOperationConductor); }
@Test public void testOperationGeneratorWithBadParamsPath() { List<Operation> generatedOps = IntStream.range(0, 10).mapToObj(i -> new Operation()).collect(Collectors.toList()); TestGeneratedOutputObject generatedOutputObject = new TestGeneratedOutputObject(generatedOps, null); doReturn(jsonHelper.getJSONString(generatedOutputObject)).when(mockOperationWrapper).getOutputPayload(); setupOperationOutputDefinition(TestGeneratedOutputObject.OPERATIONS_PATH, "/badpath"); modifier.modify(mockExecutorContext, mockOperationWrapper, mockOperationConductor); }
@Test(dataProvider = "successfulInputsProvider") public void runSuccessfulTest(List<Operation> operations, ParamsMap params, String opPath, String paramsPath) { TestGeneratedOutputObject generatedOutputObject = new TestGeneratedOutputObject(operations, params); doReturn(jsonHelper.getJSONString(generatedOutputObject)).when(mockOperationWrapper).getOutputPayload(); setupOperationOutputDefinition(opPath, paramsPath); modifier.modify(mockExecutorContext, mockOperationWrapper, mockOperationConductor); }