### Question:
MetricService { public List<Metric> collect() { final List<AvatarType> avatarTypes = List.of(AvatarType.values()); final List<Pair<AvatarType, LocalDateTime>> items = avatarUpdatedRepository.mget(avatarTypes); final long now = clock.instant().getEpochSecond(); final String graphName = mackerelProperties.getGraphs().getElapsedTime().getName(); return items.stream() .map(item -> { final String name = String.format("%s.%s", graphName, item.getKey().getId()); final long updatedAt = item.getValue().atZone(zoneId).toEpochSecond(); final BigDecimal value = BigDecimal.valueOf(now - updatedAt); return Metric.builder() .name(name) .time(now) .value(value) .build(); }) .collect(Collectors.toUnmodifiableList()); }  void log(final AvatarType avatarType); List<Metric> collect(); void send(final List<Metric> metrics);  }### Answer:
@Test public void collectTest() { final List<AvatarType> avatarTypes = Arrays.asList(AvatarType.values()); final List<Pair<AvatarType, LocalDateTime>> values = List.of( Pair.of(AvatarType.GRAVATAR, LocalDateTime.of(2019, 5, 15, 1, 2)), Pair.of(AvatarType.SLACK, LocalDateTime.of(2019, 5, 15, 8, 42)), Pair.of(AvatarType.TWITTER, LocalDateTime.of(2019, 5, 15, 15, 9)) ); final MackerelProperties.Graph graph = new MackerelProperties.Graph("graph1"); final MackerelProperties.Graphs graphs = new MackerelProperties.Graphs(graph); when(avatarUpdatedRepository.mget(avatarTypes)).thenReturn(values); when(mackerelProperties.getGraphs()).thenReturn(graphs); final List<Metric> metrics = metricService.collect(); assertEquals(3, metrics.size()); assertEquals("graph1.gravatar", metrics.get(0).getName()); assertEquals(CLOCK.instant().getEpochSecond(), metrics.get(0).getTime()); assertEquals((14 * 60 + 7) * 60, metrics.get(0).getValue().intValue()); assertEquals("graph1.slack", metrics.get(1).getName()); assertEquals(CLOCK.instant().getEpochSecond(), metrics.get(1).getTime()); assertEquals((6 * 60 + 27) * 60, metrics.get(1).getValue().intValue()); assertEquals("graph1.twitter", metrics.get(2).getName()); assertEquals(CLOCK.instant().getEpochSecond(), metrics.get(2).getTime()); assertEquals(0, metrics.get(2).getValue().intValue()); }