@Test public void testMessageAddressors() { ExperimentBase exp = mock(Experiment.class); UserRoleList roleListMock = mock(UserRoleList.class); UserRole roleOk = mock(UserRole.class); UserRole roleOk2 = mock(UserRole.class); UserRole roleBad = mock(UserRole.class); when(roleOk.getRole()).thenReturn(Role.ADMIN); when(roleOk.getUserEmail()).thenReturn("valid.email@you.org"); when(roleOk2.getUserEmail()).thenReturn("valid.email@gmail.com"); when(roleBad.getUserEmail()).thenReturn("alskdjuifa"); when(roleListMock.getRoleList()).thenReturn(Arrays.asList(roleOk, roleOk2, roleBad)); when(exp.getApplicationName()).thenReturn(appName); when(repoMock.getApplicationUsers(appName)).thenReturn(roleListMock); EventLogEvent event = new ExperimentCreateEvent(exp); Set<String> emailMessage = textProcessor.getAddressees(event); assertEquals(emailMessage.size(), 1); assertTrue(emailMessage.contains("valid.email@you.org")); assertFalse(emailMessage.contains("alskdjuifa")); }
@Override public Set<String> getAddressees(EventLogEvent event) { Set<String> addressants = new HashSet<>(); EventLogEventType type = event.getType(); switch (type) { case BUCKET_CHANGED: case BUCKET_CREATED: case EXPERIMENT_CHANGED: case EXPERIMENT_CREATED: addressants.addAll(getExperimentAddressor((ExperimentEvent) event)); break; case SIMPLE_EVENT: default: throw new IllegalArgumentException("Can not handle EventType: " + type.toString()); } return addressants; }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public Set<String> getAddressees(EventLogEvent event) { Set<String> addressants = new HashSet<>(); EventLogEventType type = event.getType(); switch (type) { case BUCKET_CHANGED: case BUCKET_CREATED: case EXPERIMENT_CHANGED: case EXPERIMENT_CREATED: addressants.addAll(getExperimentAddressor((ExperimentEvent) event)); break; case SIMPLE_EVENT: default: throw new IllegalArgumentException("Can not handle EventType: " + type.toString()); } return addressants; } }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public Set<String> getAddressees(EventLogEvent event) { Set<String> addressants = new HashSet<>(); EventLogEventType type = event.getType(); switch (type) { case BUCKET_CHANGED: case BUCKET_CREATED: case EXPERIMENT_CHANGED: case EXPERIMENT_CREATED: addressants.addAll(getExperimentAddressor((ExperimentEvent) event)); break; case SIMPLE_EVENT: default: throw new IllegalArgumentException("Can not handle EventType: " + type.toString()); } return addressants; } @Inject  EmailTextProcessorImpl(final AuthorizationRepository authorizationRepository); }
EmailTextProcessorImpl implements EmailTextProcessor { @Override public Set<String> getAddressees(EventLogEvent event) { Set<String> addressants = new HashSet<>(); EventLogEventType type = event.getType(); switch (type) { case BUCKET_CHANGED: case BUCKET_CREATED: case EXPERIMENT_CHANGED: case EXPERIMENT_CREATED: addressants.addAll(getExperimentAddressor((ExperimentEvent) event)); break; case SIMPLE_EVENT: default: throw new IllegalArgumentException("Can not handle EventType: " + type.toString()); } return addressants; } @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 Set<String> getAddressees(EventLogEvent event) { Set<String> addressants = new HashSet<>(); EventLogEventType type = event.getType(); switch (type) { case BUCKET_CHANGED: case BUCKET_CREATED: case EXPERIMENT_CHANGED: case EXPERIMENT_CREATED: addressants.addAll(getExperimentAddressor((ExperimentEvent) event)); break; case SIMPLE_EVENT: default: throw new IllegalArgumentException("Can not handle EventType: " + type.toString()); } return addressants; } @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);  }