### Question:
KubernetesOperationExecutor extends BaseOperationExecutor { protected static OperationProgress generateFailedOperationProgress(String operationName, String diagnosticMessage, Throwable t, CircularFifoQueue<String> podLogOutput) { OperationProgress operationProgress = new OperationProgress(); operationProgress.setOperation(operationName); operationProgress.setProcessingState(ProcessingState.COMPLETE); operationProgress.setProcessingStateMessage(CompleteStateMessage.FAILED.toString()); List<String> strings = IntStream.range(Math.max(0, podLogOutput.size() - DEFAULT_FAIL_DIAGNOSTIC_LINE_LIMIT), podLogOutput.size()) .mapToObj(podLogOutput::get).collect(Collectors.toList()); operationProgress.setDiagnosticEvents(new DiagnosticEvent[] { new DiagnosticEvent( diagnosticMessage, t, strings) }); return operationProgress; } KubernetesOperationExecutor(PodFollower<PodPushClient> follower, Operation operation, KubeConfig kubeConfig, PodConfig podConfig, ExecutionConfig executionConfig, ExecutorContext executorContext); void setFollower(PodFollower<PodPushClient> follower); void setKubeConfig(KubeConfig kubeConfig); void setPodConfig(PodConfig podConfig); void setExecutionConfig(ExecutionConfig executionConfig); @Override OperationProgress retrieveOperationProgress(); @Override String execute(String payload); KubeConfig getKubeConfig(); PodConfig getPodConfig(); ExecutionConfig getExecutionConfig(); static final int MAX_POD_LOG_LINES; static final int DEFAULT_FAIL_DIAGNOSTIC_LINE_LIMIT; }### Answer:
@Test(dataProvider = "generateFailedOperationProgressProvider") public void testGenerateFailedOperationProgress(final int LOG_LINES, final int EXPECTED_LOG_LINES, Exception exception) { final String OPERATION_NAME = UUID.randomUUID().toString(); final String DIAGNOSTIC_MESSAGE = UUID.randomUUID().toString(); OperationProgress operationProgress = KubernetesOperationExecutor.generateFailedOperationProgress( OPERATION_NAME, DIAGNOSTIC_MESSAGE, exception, generateLogQueue(LOG_LINES) ); Assert.assertNotNull(operationProgress); Assert.assertEquals(operationProgress.getOperation(), OPERATION_NAME); Assert.assertNotNull(operationProgress.getDiagnosticEvents()); Assert.assertEquals(operationProgress.getDiagnosticEvents().length, 1); DiagnosticEvent diagnosticEvent = operationProgress.getDiagnosticEvents()[0]; Assert.assertEquals(diagnosticEvent.getMessage(), DIAGNOSTIC_MESSAGE); if(exception != null) Assert.assertNotNull(diagnosticEvent.getStackTrace()); else Assert.assertNull(diagnosticEvent.getStackTrace()); Assert.assertNotNull(diagnosticEvent.getPayload()); Assert.assertTrue(diagnosticEvent.getPayload() instanceof List); List<String> diagnosticLines = (List<String>)diagnosticEvent.getPayload(); Assert.assertEquals(diagnosticLines.size(), EXPECTED_LOG_LINES); int diagnosticLineIndex = 0; for(int numberEntry = LOG_LINES - EXPECTED_LOG_LINES; numberEntry < LOG_LINES; numberEntry++) { Assert.assertEquals(diagnosticLines.get(diagnosticLineIndex), Integer.toString(numberEntry)); diagnosticLineIndex++; } }