@Test public void doesNotMergeWhenErrorCodeDifferent() { addError(_VIDEO_1_ID, 0, 9, "ec1", "em1"); addError(_VIDEO_1_ID, 10, 19, "ec2", "em1"); var mergedErrors = DetectionErrorUtil.getMergedDetectionErrors(_testJob); assertEquals(2, mergedErrors.size()); var issue1 = mergedErrors.get(_VIDEO_1_ID) .stream() .filter(j -> j.getCode().equals("ec1")) .findAny() .orElseThrow(); assertEquals("em1 (Frames: 0 - 9)", issue1.getMessage()); assertEquals(_TEST_ALGO1_NAME, issue1.getSource()); var issue2 = mergedErrors.get(_VIDEO_1_ID) .stream() .filter(j -> j.getCode().equals("ec2")) .findAny() .orElseThrow(); assertEquals("em1 (Frames: 10 - 19)", issue2.getMessage()); assertEquals(_TEST_ALGO1_NAME, issue2.getSource()); }
public static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job) { Multimap<Long, DetectionProcessingError> errorsIndexedByMedia = Multimaps.index(job.getDetectionProcessingErrors(), DetectionProcessingError::getMediaId); SetMultimap<Long, JsonIssueDetails> results = MultimapBuilder.hashKeys().hashSetValues().build(); for (var entry : errorsIndexedByMedia.asMap().entrySet()) { Media media = job.getMedia(entry.getKey()); Collection<DetectionProcessingError> mediaErrors = entry.getValue(); if (media.getMediaType() == MediaType.VIDEO) { results.putAll(media.getId(), mergeErrors(job, mediaErrors)); } else { List<JsonIssueDetails> issues = mediaErrors .stream() .map(d -> convertDetectionErrorToIssue(job, d)) .collect(toList()); results.putAll(media.getId(), issues); } } return results; }
DetectionErrorUtil { public static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job) { Multimap<Long, DetectionProcessingError> errorsIndexedByMedia = Multimaps.index(job.getDetectionProcessingErrors(), DetectionProcessingError::getMediaId); SetMultimap<Long, JsonIssueDetails> results = MultimapBuilder.hashKeys().hashSetValues().build(); for (var entry : errorsIndexedByMedia.asMap().entrySet()) { Media media = job.getMedia(entry.getKey()); Collection<DetectionProcessingError> mediaErrors = entry.getValue(); if (media.getMediaType() == MediaType.VIDEO) { results.putAll(media.getId(), mergeErrors(job, mediaErrors)); } else { List<JsonIssueDetails> issues = mediaErrors .stream() .map(d -> convertDetectionErrorToIssue(job, d)) .collect(toList()); results.putAll(media.getId(), issues); } } return results; } }
DetectionErrorUtil { public static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job) { Multimap<Long, DetectionProcessingError> errorsIndexedByMedia = Multimaps.index(job.getDetectionProcessingErrors(), DetectionProcessingError::getMediaId); SetMultimap<Long, JsonIssueDetails> results = MultimapBuilder.hashKeys().hashSetValues().build(); for (var entry : errorsIndexedByMedia.asMap().entrySet()) { Media media = job.getMedia(entry.getKey()); Collection<DetectionProcessingError> mediaErrors = entry.getValue(); if (media.getMediaType() == MediaType.VIDEO) { results.putAll(media.getId(), mergeErrors(job, mediaErrors)); } else { List<JsonIssueDetails> issues = mediaErrors .stream() .map(d -> convertDetectionErrorToIssue(job, d)) .collect(toList()); results.putAll(media.getId(), issues); } } return results; } private  DetectionErrorUtil(); }
DetectionErrorUtil { public static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job) { Multimap<Long, DetectionProcessingError> errorsIndexedByMedia = Multimaps.index(job.getDetectionProcessingErrors(), DetectionProcessingError::getMediaId); SetMultimap<Long, JsonIssueDetails> results = MultimapBuilder.hashKeys().hashSetValues().build(); for (var entry : errorsIndexedByMedia.asMap().entrySet()) { Media media = job.getMedia(entry.getKey()); Collection<DetectionProcessingError> mediaErrors = entry.getValue(); if (media.getMediaType() == MediaType.VIDEO) { results.putAll(media.getId(), mergeErrors(job, mediaErrors)); } else { List<JsonIssueDetails> issues = mediaErrors .stream() .map(d -> convertDetectionErrorToIssue(job, d)) .collect(toList()); results.putAll(media.getId(), issues); } } return results; } private  DetectionErrorUtil(); static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job); static Collector<Integer, ?, Optional<String>> toFrameRangesString(); }
DetectionErrorUtil { public static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job) { Multimap<Long, DetectionProcessingError> errorsIndexedByMedia = Multimaps.index(job.getDetectionProcessingErrors(), DetectionProcessingError::getMediaId); SetMultimap<Long, JsonIssueDetails> results = MultimapBuilder.hashKeys().hashSetValues().build(); for (var entry : errorsIndexedByMedia.asMap().entrySet()) { Media media = job.getMedia(entry.getKey()); Collection<DetectionProcessingError> mediaErrors = entry.getValue(); if (media.getMediaType() == MediaType.VIDEO) { results.putAll(media.getId(), mergeErrors(job, mediaErrors)); } else { List<JsonIssueDetails> issues = mediaErrors .stream() .map(d -> convertDetectionErrorToIssue(job, d)) .collect(toList()); results.putAll(media.getId(), issues); } } return results; } private  DetectionErrorUtil(); static Multimap<Long, JsonIssueDetails> getMergedDetectionErrors(BatchJob job); static Collector<Integer, ?, Optional<String>> toFrameRangesString();  }