@Test(dataProvider = "updateProgressItemsToReportProvider") public void testUpdateProgressItemsToReport(ProcessingState processingState, int expectedRetrieverSize, int expectedProgressItemsToReport) { Set<OperationProgressProvider> retrieverSet = createOperationProgressRetrievers(1); OperationProgressProvider operationProgressProvider = (OperationProgressProvider)retrieverSet.toArray()[0]; OperationProgress operationProgress = new OperationProgress(); operationProgress.setProcessingState(processingState); doReturn(operationProgress).when(operationProgressProvider).retrieveOperationProgress(); agendaProgressThread = new AgendaProgressThread(mockAgendaProgressThreadConfig); agendaProgressThread.setOperationProgressProviders(retrieverSet); agendaProgressThread.updateProgressItemsToReport(); Assert.assertEquals(agendaProgressThread.getOperationProgressProviders().size(), expectedRetrieverSize); Assert.assertEquals(agendaProgressThread.getOperationProgressToReport().size(), expectedProgressItemsToReport); }
@Override protected synchronized void updateProgressItemsToReport() { if(operationProgressProviders == null || operationProgressProviders.size() == 0) return; List<OperationProgressProvider> operationProgressRetrieversToRemove = new LinkedList<>(); double incompleteOperationPercentTotal = 0; for(OperationProgressProvider opr : operationProgressProviders) { OperationProgress operationProgress = opr.retrieveOperationProgress(); if(operationProgress != null && operationProgress.getProcessingState() != null) { switch (operationProgress.getProcessingState()) { case EXECUTING: operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); if(operationProgress.getPercentComplete() != null) { incompleteOperationPercentTotal += Math.min(100d, operationProgress.getPercentComplete()); } operationProgressToReport.add(operationProgress); break; case COMPLETE: processCompleteOperationProgress(operationProgress); completedProgressOperationCount++; operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); operationProgressToReport.add(operationProgress); operationProgressRetrieversToRemove.add(opr); break; } } } overallProgressPercentComplete = calculatePercentComplete(completedProgressOperationCount, totalProgressOperationCount, incompleteOperationPercentTotal); operationProgressRetrieversToRemove.forEach(opr -> operationProgressProviders.remove(opr)); }
AgendaProgressThread extends BaseReporterThread<AgendaProgressThreadConfig> implements AgendaProgressConsumer { @Override protected synchronized void updateProgressItemsToReport() { if(operationProgressProviders == null || operationProgressProviders.size() == 0) return; List<OperationProgressProvider> operationProgressRetrieversToRemove = new LinkedList<>(); double incompleteOperationPercentTotal = 0; for(OperationProgressProvider opr : operationProgressProviders) { OperationProgress operationProgress = opr.retrieveOperationProgress(); if(operationProgress != null && operationProgress.getProcessingState() != null) { switch (operationProgress.getProcessingState()) { case EXECUTING: operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); if(operationProgress.getPercentComplete() != null) { incompleteOperationPercentTotal += Math.min(100d, operationProgress.getPercentComplete()); } operationProgressToReport.add(operationProgress); break; case COMPLETE: processCompleteOperationProgress(operationProgress); completedProgressOperationCount++; operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); operationProgressToReport.add(operationProgress); operationProgressRetrieversToRemove.add(opr); break; } } } overallProgressPercentComplete = calculatePercentComplete(completedProgressOperationCount, totalProgressOperationCount, incompleteOperationPercentTotal); operationProgressRetrieversToRemove.forEach(opr -> operationProgressProviders.remove(opr)); } }
AgendaProgressThread extends BaseReporterThread<AgendaProgressThreadConfig> implements AgendaProgressConsumer { @Override protected synchronized void updateProgressItemsToReport() { if(operationProgressProviders == null || operationProgressProviders.size() == 0) return; List<OperationProgressProvider> operationProgressRetrieversToRemove = new LinkedList<>(); double incompleteOperationPercentTotal = 0; for(OperationProgressProvider opr : operationProgressProviders) { OperationProgress operationProgress = opr.retrieveOperationProgress(); if(operationProgress != null && operationProgress.getProcessingState() != null) { switch (operationProgress.getProcessingState()) { case EXECUTING: operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); if(operationProgress.getPercentComplete() != null) { incompleteOperationPercentTotal += Math.min(100d, operationProgress.getPercentComplete()); } operationProgressToReport.add(operationProgress); break; case COMPLETE: processCompleteOperationProgress(operationProgress); completedProgressOperationCount++; operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); operationProgressToReport.add(operationProgress); operationProgressRetrieversToRemove.add(opr); break; } } } overallProgressPercentComplete = calculatePercentComplete(completedProgressOperationCount, totalProgressOperationCount, incompleteOperationPercentTotal); operationProgressRetrieversToRemove.forEach(opr -> operationProgressProviders.remove(opr)); } AgendaProgressThread(AgendaProgressThreadConfig agendaProgressThreadConfig); }
AgendaProgressThread extends BaseReporterThread<AgendaProgressThreadConfig> implements AgendaProgressConsumer { @Override protected synchronized void updateProgressItemsToReport() { if(operationProgressProviders == null || operationProgressProviders.size() == 0) return; List<OperationProgressProvider> operationProgressRetrieversToRemove = new LinkedList<>(); double incompleteOperationPercentTotal = 0; for(OperationProgressProvider opr : operationProgressProviders) { OperationProgress operationProgress = opr.retrieveOperationProgress(); if(operationProgress != null && operationProgress.getProcessingState() != null) { switch (operationProgress.getProcessingState()) { case EXECUTING: operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); if(operationProgress.getPercentComplete() != null) { incompleteOperationPercentTotal += Math.min(100d, operationProgress.getPercentComplete()); } operationProgressToReport.add(operationProgress); break; case COMPLETE: processCompleteOperationProgress(operationProgress); completedProgressOperationCount++; operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); operationProgressToReport.add(operationProgress); operationProgressRetrieversToRemove.add(opr); break; } } } overallProgressPercentComplete = calculatePercentComplete(completedProgressOperationCount, totalProgressOperationCount, incompleteOperationPercentTotal); operationProgressRetrieversToRemove.forEach(opr -> operationProgressProviders.remove(opr)); } AgendaProgressThread(AgendaProgressThreadConfig agendaProgressThreadConfig); @Override synchronized void setAgendaProgress(AgendaProgress agendaProgress); @Override synchronized void registerOperationProgressProvider(OperationProgressProvider operationProgressProvder); @Override synchronized void setTotalProgressOperationCount(int totalProgressOperationCount); @Override synchronized void adjustTotalProgressOperationCount(int operationTotalCountAdjustment); @Override synchronized void incrementCompletedOperationCount(int incrementAmount); }
AgendaProgressThread extends BaseReporterThread<AgendaProgressThreadConfig> implements AgendaProgressConsumer { @Override protected synchronized void updateProgressItemsToReport() { if(operationProgressProviders == null || operationProgressProviders.size() == 0) return; List<OperationProgressProvider> operationProgressRetrieversToRemove = new LinkedList<>(); double incompleteOperationPercentTotal = 0; for(OperationProgressProvider opr : operationProgressProviders) { OperationProgress operationProgress = opr.retrieveOperationProgress(); if(operationProgress != null && operationProgress.getProcessingState() != null) { switch (operationProgress.getProcessingState()) { case EXECUTING: operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); if(operationProgress.getPercentComplete() != null) { incompleteOperationPercentTotal += Math.min(100d, operationProgress.getPercentComplete()); } operationProgressToReport.add(operationProgress); break; case COMPLETE: processCompleteOperationProgress(operationProgress); completedProgressOperationCount++; operationProgressToReport.removeIf(op -> StringUtils.equals(operationProgress.getOperation(), op.getOperation())); operationProgressToReport.add(operationProgress); operationProgressRetrieversToRemove.add(opr); break; } } } overallProgressPercentComplete = calculatePercentComplete(completedProgressOperationCount, totalProgressOperationCount, incompleteOperationPercentTotal); operationProgressRetrieversToRemove.forEach(opr -> operationProgressProviders.remove(opr)); } AgendaProgressThread(AgendaProgressThreadConfig agendaProgressThreadConfig); @Override synchronized void setAgendaProgress(AgendaProgress agendaProgress); @Override synchronized void registerOperationProgressProvider(OperationProgressProvider operationProgressProvder); @Override synchronized void setTotalProgressOperationCount(int totalProgressOperationCount); @Override synchronized void adjustTotalProgressOperationCount(int operationTotalCountAdjustment); @Override synchronized void incrementCompletedOperationCount(int incrementAmount);  }