public void test_1_GetDefautSetting() throws Exception { for (int i = 0; i < 10; i++) { User user = new UserImpl("user_" + i); organizationService.getUserHandler().createUser(user, false); } // before upgrade List<UserSetting> list = userSettingService.getDigestDefaultSettingForAllUser(0, 0); int size = list.size(); // run upgrade runUpgrade(); // after upgrade list = userSettingService.getDigestDefaultSettingForAllUser(0, 0); assertTrue(list.size() > size); }
public void test_2_GetUsersSetting() throws Exception { runUpgrade(); // userSettingService.save( createUserSetting( "root", Arrays.asList("1", "2"), Arrays.asList("3", "4"), Arrays.asList("5", "6"))); userSettingService.save( createUserSetting( "john", Arrays.asList("4", "5"), Arrays.asList("2", "8"), Arrays.asList("6", "7"))); userSettingService.save( createUserSetting( "mary", Arrays.asList("32", "5"), Arrays.asList("4", "6"), Arrays.asList("1", "9"))); userSettingService.save( createUserSetting( "demo", Arrays.asList("2"), Arrays.asList("3", "9"), Arrays.asList("2", "7"))); // List<String> list = userSettingService.getUserSettingByPlugin("2"); assertEquals(3, list.size()); // root, john, demo // disable user "root" CommonsUtils.getService(OrganizationService.class) .getUserHandler() .setEnabled("root", false, true); list = userSettingService.getUserSettingByPlugin("2"); assertEquals(2, list.size()); // john, demo }
public void testDisabledUser() throws Exception { User u = CommonsUtils.getService(OrganizationService.class) .getUserHandler() .createUserInstance("binh"); u.setEmail("email@test"); u.setFirstName("first"); u.setLastName("last"); u.setPassword("pwdADDSomeSaltToBeCompliantWithSomeIS00"); CommonsUtils.getService(OrganizationService.class).getUserHandler().createUser(u, true); userSettingService.save(createUserSetting("binh", null, null, null)); UserSetting userSetting = userSettingService.get("binh"); assertTrue(userSetting.isChannelActive(MailChannel.ID)); assertTrue(userSetting.isEnabled()); // disable user "root" CommonsUtils.getService(OrganizationService.class) .getUserHandler() .setEnabled("binh", false, true); userSetting = userSettingService.get("binh"); assertTrue(userSetting.isChannelActive(MailChannel.ID)); assertFalse(userSetting.isEnabled()); // enable user "root" but not change the active channel status CommonsUtils.getService(OrganizationService.class) .getUserHandler() .setEnabled("binh", true, true); userSetting = userSettingService.get("binh"); assertTrue(userSetting.isChannelActive(MailChannel.ID)); assertTrue(userSetting.isEnabled()); CommonsUtils.getService(OrganizationService.class).getUserHandler().removeUser("binh", false); assertNull( CommonsUtils.getService(OrganizationService.class).getUserHandler().findUserByName("binh")); }