use of com.thoughtworks.go.domain.NotificationFilter in project gocd by gocd.
the class StageNotificationServiceTest method prepareOneMatchedUser.
private String prepareOneMatchedUser() {
String jezMail = "jez@cruise.com";
User jez = new User("jez", new String[] { "lgao" }, jezMail, true);
jez.setNotificationFilters(Arrays.asList(new NotificationFilter("go", "dev", StageEvent.All, true)));
when(userService.findValidSubscribers(new StageConfigIdentifier("go", "dev"))).thenReturn(new Users(Arrays.asList(jez)));
return jezMail;
}
use of com.thoughtworks.go.domain.NotificationFilter in project gocd by gocd.
the class MyGoControllerTest method shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase.
@Test
public void shouldRenderPipelineStageCombinationJSONSortedByPipelineNameIgnoringCase() {
HttpServletRequest request = mock(HttpServletRequest.class);
User user = new User(USERNAME, "Srikanth Maga", new String[] { "rope", "srikanth" }, "sriki@tw.com", true);
user.addNotificationFilter(new NotificationFilter("p1", "s1", StageEvent.All, true));
user.addNotificationFilter(new NotificationFilter("p2", "s2", StageEvent.Fails, true));
when(userService.load(USERID)).thenReturn(user);
List<PipelineConfigs> groups = new ArrayList<>();
groups.add(PipelineConfigMother.createGroup("g3", PipelineConfigMother.createPipelineConfigWithStages("pipeline3-1", "stage3-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("PIPELINE2-1", "stage2-1")));
groups.add(PipelineConfigMother.createGroup("g1", PipelineConfigMother.createPipelineConfigWithStages("pipeline1-1", "stage1-1", "stage1-2")));
when(pipelineConfigService.viewableGroupsFor(new Username(new CaseInsensitiveString(user.getName())))).thenReturn(groups);
ModelAndView modelAndView = controller.handleRequest(null, request);
assertThat(modelAndView.getModel().get("matchers"), is(new Matcher("rope,srikanth")));
assertThat(modelAndView.getModel().get("email"), is("sriki@tw.com"));
assertThat(modelAndView.getModel().get("emailMe"), is(true));
assertThat(modelAndView.getModel().get("notificationFilters"), is(user.getNotificationFilters()));
assertThat(modelAndView.getModel().get("l"), is(localizer));
assertThat(modelAndView.getModel().get("pipelines"), is("[{\"name\":\"" + GoConstants.ANY_PIPELINE + "\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"}]}," + "{\"name\":\"pipeline1-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage1-1\"},{\"stageName\":\"stage1-2\"}]}," + "{\"name\":\"PIPELINE2-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage2-1\"}]}," + "{\"name\":\"pipeline3-1\",\"stages\":[{\"stageName\":\"" + GoConstants.ANY_STAGE + "\"},{\"stageName\":\"stage3-1\"}]}]"));
}
use of com.thoughtworks.go.domain.NotificationFilter in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method prepareOneNotMatchedUser.
private String prepareOneNotMatchedUser() {
String chrisMail = "chris@cruise.com";
User chris = new User("chris", new String[] { "will not be matched" }, chrisMail, true);
chris.addNotificationFilter(new NotificationFilter(pipelineFixture.pipelineName, pipelineFixture.ftStage, StageEvent.All, true));
userDao.saveOrUpdate(chris);
return chrisMail;
}
use of com.thoughtworks.go.domain.NotificationFilter in project gocd by gocd.
the class StageNotificationServiceIntegrationTest method prepareOneMatchedUser.
private String prepareOneMatchedUser(StageEvent event) {
String jezMail = "jez@cruise.com";
User jez = new User("jez", new String[] { "lgao" }, jezMail, true);
jez.addNotificationFilter(new NotificationFilter(pipelineFixture.pipelineName, pipelineFixture.ftStage, event, true));
userDao.saveOrUpdate(jez);
return jezMail;
}
use of com.thoughtworks.go.domain.NotificationFilter in project gocd by gocd.
the class UserSqlMapDaoCachingTest method shouldCacheUserOnFind.
@Test
public void shouldCacheUserOnFind() {
User first = new User("first");
first.addNotificationFilter(new NotificationFilter("pipline", "stage1", StageEvent.Fails, true));
first.addNotificationFilter(new NotificationFilter("pipline", "stage2", StageEvent.Fails, true));
int originalUserCacheSize = sessionFactory.getStatistics().getSecondLevelCacheStatistics(User.class.getCanonicalName()).getEntries().size();
int originalNotificationsCacheSize = sessionFactory.getStatistics().getSecondLevelCacheStatistics(User.class.getCanonicalName() + ".notificationFilters").getEntries().size();
userDao.saveOrUpdate(first);
long userId = userDao.findUser("first").getId();
assertThat(sessionFactory.getStatistics().getSecondLevelCacheStatistics(User.class.getCanonicalName()).getEntries().size(), is(originalUserCacheSize + 1));
SecondLevelCacheStatistics notificationFilterCollectionCache = sessionFactory.getStatistics().getSecondLevelCacheStatistics(User.class.getCanonicalName() + ".notificationFilters");
assertThat(notificationFilterCollectionCache.getEntries().size(), is(originalNotificationsCacheSize + 1));
assertThat(notificationFilterCollectionCache.getEntries().get(userId), is(Matchers.notNullValue()));
}
Aggregations