1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*******************************************************************************
* Copyright (c) 2010 Boeing.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.ats.column;
import java.util.Calendar;
import java.util.Date;
import org.eclipse.osee.ats.core.AtsTestUtil;
import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
import org.eclipse.osee.ats.util.AtsUtil;
import org.eclipse.osee.ats.util.DemoTestUtil;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.logging.SevereLoggingMonitor;
import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.support.test.util.TestUtil;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
/**
* @tests DeadlineColumn
* @author Donald G. Dunne
*/
public class DeadlineColumnTest {
@BeforeClass
@AfterClass
public static void cleanup() throws Exception {
AtsTestUtil.cleanupSimpleTest(DeadlineColumnTest.class.getSimpleName());
}
@org.junit.Test
public void testGetColumnText() throws Exception {
SevereLoggingMonitor loggingMonitor = TestUtil.severeLoggingStart();
SkynetTransaction transaction =
TransactionManager.createTransaction(AtsUtil.getAtsBranch(), CancelledDateColumnTest.class.getSimpleName());
TeamWorkFlowArtifact teamArt =
DemoTestUtil.createSimpleAction(CancelledDateColumnTest.class.getSimpleName(), transaction);
transaction.execute();
Assert.assertNull(DeadlineColumn.getDate(teamArt));
Date creationDate = teamArt.getCreatedDate();
Calendar calendar = DateUtil.getCalendar(creationDate);
calendar.add(Calendar.DAY_OF_MONTH, -1);
Date overdueDate = calendar.getTime();
teamArt.setSoleAttributeValue(AtsAttributeTypes.NeedBy, overdueDate);
teamArt.persist(getClass().getSimpleName());
Assert.assertEquals(overdueDate, DeadlineColumn.getDate(teamArt));
Assert.assertTrue(DeadlineColumn.isDeadlineAlerting(teamArt).isTrue());
Assert.assertNotNull(DeadlineColumn.getInstance().getColumnImage(teamArt, DeadlineColumn.getInstance(), 0));
calendar = DateUtil.getCalendar(creationDate);
calendar.add(Calendar.DAY_OF_MONTH, +5);
Date futureDate = calendar.getTime();
teamArt.setSoleAttributeValue(AtsAttributeTypes.NeedBy, futureDate);
teamArt.persist(getClass().getSimpleName());
Assert.assertEquals(futureDate, DeadlineColumn.getDate(teamArt));
Assert.assertTrue(DeadlineColumn.isDeadlineAlerting(teamArt).isFalse());
Assert.assertNull(DeadlineColumn.getInstance().getColumnImage(teamArt, DeadlineColumn.getInstance(), 0));
TestUtil.severeLoggingEnd(loggingMonitor);
}
}
|