EmailBuilder implements InternalSystemEventVisitor<Email> { @Override public Email visit(QueryProcessed queryProcessed) { return null; } EmailBuilder(RichEmailBuilder richEmailBuilder); @Override Email visit(QueryProcessed queryProcessed); @Override Email visit(QueryProcessingError queryProcessingError);  }
@Test public void testCardinalityEmailBuild() throws JsonProcessingException { EmailBuilder emailBuilder = new EmailBuilder(new RichEmailBuilder(new StrSubstitutorEmailSubjectBuilder(), new StrSubstitutorEmailBodyBuilder())); GroupRequest groupRequest = new GroupRequest(); groupRequest.setTable(TestUtils.TEST_TABLE_NAME); groupRequest.setNesting(Lists.newArrayList("os", "deviceId")); QueryProcessingError error = new QueryProcessingError( groupRequest, new CardinalityOverflowException(groupRequest, Jackson.newObjectMapper() .writeValueAsString( groupRequest), "deviceId", 0.75)); final Email email = emailBuilder.visit(error); Assert.assertEquals("Blocked query as it might have screwed up the cluster", email.getSubject()); Assert.assertEquals( "Blocked Query: {\"opcode\":\"group\",\"filters\":[],\"bypassCache\":false,\"table\":\"test-table\"," + "\"uniqueCountOn\":null,\"nesting\":[\"os\",\"deviceId\"],\"precision\":null}\n" + "Suspect field: deviceId\n" + "Probability of screwing up the cluster: 0.75", email.getContent()); }