Skip to content

Commit

Permalink
Fix test for mail send of event
Browse files Browse the repository at this point in the history
  • Loading branch information
koda-masaru committed Mar 11, 2017
1 parent 1c0c194 commit e40a137
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ private void notifyMin(EventsEntity event, KnowledgesEntity knowledge, List<Know
return;
}
if (LOG.isDebugEnabled()) {
LOG.debug(": " + (event.getStartDateTime().getTime() - now.getTimeInMillis()));
LOG.debug("開始までの時間: " + (event.getStartDateTime().getTime() - now.getTimeInMillis()));
}
// 30分を切った?
if (event.getStartDateTime().getTime() - now.getTimeInMillis() > (1000 * 60 * 30)) {
if (event.getStartDateTime().getTime() <= now.getTimeInMillis() ||
event.getStartDateTime().getTime() - now.getTimeInMillis() > (1000 * 60 * 30)) {
return;
}
LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 30分前");
sendNotify(event, knowledge, values, timing);
}

Expand All @@ -148,6 +150,7 @@ private void notifyDate(EventsEntity event, KnowledgesEntity knowledge, List<Kno
// イベント当日以外は通知しない
return;
}
LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 本日開催");
sendNotify(event, knowledge, values, timing);
}

Expand All @@ -166,7 +169,7 @@ private void notifyWeek(EventsEntity event, KnowledgesEntity knowledge, List<Kno
// 日曜日でない場合は通知しない
return;
}

LOG.info("イベントのメール通知 [ID] " + knowledge.getKnowledgeId() + " [Timing] 今週開催");
sendNotify(event, knowledge, values, timing);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
import org.junit.Test;
import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.common.test.Order;
import org.support.project.knowledge.TestCommon;
import org.support.project.knowledge.config.AppConfig;
import org.support.project.knowledge.config.SystemConfig;
import org.support.project.knowledge.dao.EventsDao;
import org.support.project.knowledge.dao.KnowledgeItemValuesDao;
import org.support.project.knowledge.dao.KnowledgesDao;
import org.support.project.knowledge.dao.LikesDao;
import org.support.project.knowledge.dao.ParticipantsDao;
import org.support.project.knowledge.dao.StockKnowledgesDao;
import org.support.project.knowledge.dao.TemplateMastersDao;
import org.support.project.knowledge.entity.EventsEntity;
import org.support.project.knowledge.entity.KnowledgeItemValuesEntity;
import org.support.project.knowledge.entity.KnowledgesEntity;
import org.support.project.knowledge.entity.LikesEntity;
import org.support.project.knowledge.entity.ParticipantsEntity;
import org.support.project.knowledge.entity.StockKnowledgesEntity;
import org.support.project.knowledge.entity.TemplateItemsEntity;
Expand Down Expand Up @@ -104,6 +103,7 @@ public void setUp() throws Exception {
* @throws Exception
*/
@Test
@Order(order = 1)
public void testNotifyEvents() throws Exception {
KnowledgesEntity knowledge = new KnowledgesEntity();
knowledge.setTitle("Sample1");
Expand All @@ -124,6 +124,7 @@ public void testNotifyEvents() throws Exception {
for (TemplateItemsEntity item : items) {
if (item.getItemNo() == EventsLogic.ITEM_NO_DATE) {
item.setItemValue(dateFormat.format(new Date(now.getTimeInMillis())));
LOG.info(item.getItemValue());
} else if (item.getItemNo() == EventsLogic.ITEM_NO_START) {
item.setItemValue("11:00");
} else if (item.getItemNo() == EventsLogic.ITEM_NO_END) {
Expand Down Expand Up @@ -153,6 +154,7 @@ public void testNotifyEvents() throws Exception {
Calendar today = Calendar.getInstance(timezone);
EventsLogic.get().logging(today);
if (today.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
LOG.info("Today is sunday.");
Assert.assertEquals(1, mails.size());
} else {
Assert.assertEquals(0, mails.size());
Expand All @@ -167,6 +169,7 @@ public void testNotifyEvents() throws Exception {
* @throws Exception
*/
@Test
@Order(order = 2)
public void testNotifyEvents2() throws Exception {
KnowledgesEntity knowledge = new KnowledgesEntity();
knowledge.setTitle("Sample2");
Expand Down Expand Up @@ -226,6 +229,7 @@ public void testNotifyEvents2() throws Exception {
* @throws Exception
*/
@Test
@Order(order = 3)
public void testNotifyEvents3() throws Exception {
KnowledgesEntity knowledge = new KnowledgesEntity();
knowledge.setTitle("Sample3");
Expand Down

0 comments on commit e40a137

Please sign in to comment.