@Test @Order(order = 6) public void testNotify6() throws Exception { NotifyConfigsEntity notifyConfigs = new NotifyConfigsEntity(); notifyConfigs.setUserId(loginedUser2.getUserId()); notifyConfigs.setNotifyMail(INT_FLAG.ON.getValue()); notifyConfigs.setNotifyDesktop(INT_FLAG.ON.getValue()); notifyConfigs.setMyItemComment(INT_FLAG.ON.getValue()); notifyConfigs.setToItemComment(INT_FLAG.OFF.getValue()); NotifyConfigsDao.get().save(notifyConfigs); KnowledgesEntity knowledge = knowledge3; // 公開のナレッジにコメント登録 CommentsEntity comment = new CommentsEntity(); comment.setKnowledgeId(knowledge.getKnowledgeId()); CommentsDao.get().save(comment); UsersEntity user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Desktop, comment, knowledge); Assert.assertEquals(loginedUser.getUserId(), user.getUserId()); user = NotifyCommentLogic.get().getInsertUserOnComment(NotifyType.Mail, comment, knowledge); Assert.assertEquals(loginedUser.getUserId(), user.getUserId()); List<UsersEntity> users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Desktop, comment, knowledge); Assert.assertEquals(0, users.size()); users = NotifyCommentLogic.get().getTargetUsersOnComment(NotifyType.Mail, comment, knowledge); Assert.assertEquals(0, users.size()); }
@Post @Auth(roles = "admin") public Boundary test() throws Exception { try { ProxyConfigsEntity entity; String testUrl = getParam("testUrl"); Integer testType = getParam("testType", Integer.class); if (INT_FLAG.OFF.getValue() == testType.intValue()) { entity = new ProxyConfigsEntity(); } else { List<ValidateError> errors = new ArrayList<>(); errors.addAll(ProxyConfigsEntity.get().validate(getParams())); String type = getParam("proxyAuthType"); // 認証がONの場合のチェック if (!type.equals(String.valueOf(AuthType.None.getValue()))) { if (StringUtils.isEmpty(getParam("proxyAuthUserId"))) { ValidateError error = new ValidateError("errors.required", getResource("label.auth.id")); errors.add(error); } if (StringUtils.isEmpty(getParam("proxyAuthPassword"))) { ValidateError error = new ValidateError("errors.required", getResource("label.auth.password")); errors.add(error); } } if (!errors.isEmpty()) { setResult(null, errors); return forward("config.jsp"); } entity = super.getParamOnProperty(ProxyConfigsEntity.class); ProxyConfigsDao dao = ProxyConfigsDao.get(); if (entity.getProxyAuthPassword().equals(NO_CHANGE_PASSWORD)) { // パスワード変更無し ProxyConfigsEntity db = dao.selectOnKey(AppConfig.get().getSystemName()); entity.setProxyAuthPassword(db.getProxyAuthPassword()); entity.setProxyAuthSalt(db.getProxyAuthSalt()); } else { // パスワードは暗号化する String salt = PasswordUtil.getSalt(); entity.setProxyAuthPassword(PasswordUtil.encrypt(entity.getProxyAuthPassword(), salt)); entity.setProxyAuthSalt(salt); } } // 確認用のURLで通信出来るか確認 CrawlerLogic crawlerLogic = CrawlerLogic.get(); String content = crawlerLogic.crawle(entity, testUrl); setAttribute("content", content); addMsgInfo("knowledge.proxy.test.done"); } catch (Exception e) { LOG.warn("knowledge.proxy.test.fail", e); addMsgError("knowledge.proxy.test.fail"); addMsgError(e.getClass().getSimpleName()); if (StringUtils.isNotEmpty(e.getMessage())) { addMsgError(e.getMessage()); } } return forward("config.jsp"); }