Use stream-collect rather than transformValues in Spec11 collection

As it turns out, using Maps::transformValues does not allow us to change the
resulting map--calling Map::put throws an UnsupportedOperationException. As a
result, we have to do this roundabout stream-collect to do a group-by.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=244852373
This commit is contained in:
gbrodman 2019-04-23 07:44:06 -07:00 committed by jianglai
parent 143ae1f93e
commit 0644fab76e
2 changed files with 47 additions and 25 deletions

View file

@ -199,6 +199,24 @@ public class PublishSpec11ReportActionTest {
verifyNoMoreInteractions(emailUtils);
}
@Test
public void testJobDone_noDifferentResults() throws Exception {
LocalDate yesterday = date.minusDays(1);
when(parser.getPreviousDateWithMatches(date)).thenReturn(Optional.of(yesterday));
when(parser.getRegistrarThreatMatches(date)).thenReturn(sampleThreatMatches());
when(parser.getRegistrarThreatMatches(yesterday)).thenReturn(sampleThreatMatches());
expectedJob.setCurrentState("JOB_STATE_DONE");
publishAction.run();
assertThat(response.getStatus()).isEqualTo(SC_OK);
verify(emailUtils)
.emailSpec11Reports(
date,
Spec11EmailSoyInfo.DAILY_SPEC_11_EMAIL,
"Super Cool Registry Daily Threat Detector [2018-06-05]",
ImmutableSet.of());
verifyNoMoreInteractions(emailUtils);
}
@Test
public void testJobDone_failsDueToNoPreviousResults() {
when(parser.getPreviousDateWithMatches(date)).thenReturn(Optional.empty());