@Test(expected = IllegalArgumentException.class) public void testMessageExtraction() { BucketCreateEvent mockedEventLog = mock(BucketCreateEvent.class); ExperimentBase mockedExperimentBase = mock(ExperimentBase.class); Bucket mockedBucket = mock(Bucket.class); Experiment.Label experimentLabel = mock(Experiment.Label.class); Bucket.Label bucketLabel = mock(Bucket.Label.class); when(experimentLabel.toString()).thenReturn("mockedExperimentLabel"); when(bucketLabel.toString()).thenReturn("mockedBucketLabel"); when(mockedEventLog.getBucket()).thenReturn(mockedBucket); when(mockedBucket.getLabel()).thenReturn(bucketLabel); when(mockedExperimentBase.getLabel()).thenReturn(experimentLabel); when(mockedEventLog.getExperiment()).thenReturn(mockedExperimentBase); when(mockedEventLog.getType()).thenReturn(EventLogEventType.BUCKET_CREATED); String message = textProcessor.getMessage(mockedEventLog); assertThat(message, is(not(nullValue()))); when(mockedEventLog.getType()).thenReturn(EventLogEventType.UNKNOWN); message = textProcessor.getMessage(mockedEventLog); fail(); }
@Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); } }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); } @Inject  EmailTextProcessorImpl(final AuthorizationRepository authorizationRepository); }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); } @Inject  EmailTextProcessorImpl(final AuthorizationRepository authorizationRepository); @Override Set<String> getAddressees(EventLogEvent event); @Override Set<String> getAddressees(Application.Name app); @Override String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links); @Override String getSubject(Application.Name app); @Override String getSubject(EventLogEvent event); @Override String getMessage(EventLogEvent event); }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links) { ST appAccess = new ST(APP_ACCESS); Map<String, String> variables = new HashMap<>(); put(variables, APPLICATION_NAME, String.valueOf(app)); put(variables, USER_NAME, String.valueOf(username)); put(variables, EMAIL_LINKS, links.toString()); return replaceVariablesInTemplate(variables, appAccess); } @Inject  EmailTextProcessorImpl(final AuthorizationRepository authorizationRepository); @Override Set<String> getAddressees(EventLogEvent event); @Override Set<String> getAddressees(Application.Name app); @Override String getMessage(Application.Name app, UserInfo.Username username, EmailLinksList links); @Override String getSubject(Application.Name app); @Override String getSubject(EventLogEvent event); @Override String getMessage(EventLogEvent event);  }