AccountTest.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import cn.reghao.devops.manager.ManagerApplication;
  2. import cn.reghao.devops.manager.notification.NotifyService;
  3. import cn.reghao.devops.manager.notification.notifier.ding.DingMsg;
  4. import cn.reghao.devops.manager.rbac.service.UserService;
  5. import lombok.extern.slf4j.Slf4j;
  6. import org.junit.Test;
  7. import org.junit.runner.RunWith;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.boot.test.context.SpringBootTest;
  10. import org.springframework.test.context.ActiveProfiles;
  11. import org.springframework.test.context.junit4.SpringRunner;
  12. /**
  13. * @author reghao
  14. * @date 2022-08-17 15:53:04
  15. */
  16. @Slf4j
  17. @ActiveProfiles("dev")
  18. @SpringBootTest(classes = ManagerApplication.class)
  19. @RunWith(SpringRunner.class)
  20. public class AccountTest {
  21. @Autowired
  22. UserService userService;
  23. @Test
  24. public void createAccount() {
  25. String username = "admin";
  26. int userId = 102;
  27. String password = "ecUgpUeIX2ub84EYPsiQ";
  28. userService.modifyUserPassword(userId, password);
  29. /*String role = RoleType.ROLE_ADMIN.name();
  30. User user = new User(username, password, Set.of(new UserAuthority(role)));
  31. userService.createUser(user);*/
  32. }
  33. @Autowired
  34. NotifyService notifyService;
  35. @Test
  36. public void notifyTest() throws InterruptedException {
  37. String title = "测试";
  38. String text = "应用测试内容";
  39. DingMsg dingMsg = new DingMsg(title, text);
  40. notifyService.notify(dingMsg);
  41. Thread.sleep(3600_000);
  42. }
  43. }