public static void validateItem(IAtsUser user, IAtsLogItem item, Date date) throws OseeCoreException { Assert.assertEquals(LogType.Error, item.getType()); Assert.assertEquals(date, item.getDate()); Assert.assertEquals(user.getUserId(), item.getUserId()); Assert.assertEquals("Analyze", item.getState()); Assert.assertEquals("my msg", item.getMsg()); }
@Test public void testToString() throws OseeCoreException { Date date = new Date(); IAtsLogItem item = getTestLogItem(date, user); Assert.assertEquals( "my msg (Error)from Analyze by " + user.getName() + " on " + DateUtil.getMMDDYYHHMM(date), item.toString()); }
@Test public void testDatePattern() { Calendar cal = Calendar.getInstance(); cal.set(2011, 10, 1); Date date = cal.getTime(); IAtsLogItem item = getTestLogItem(date, user); Assert.assertEquals(date.toString(), item.getDate(null)); Assert.assertEquals("11/01/2011", item.getDate("MM/dd/yyyy")); }
@Test public void testSetsAndGets() throws OseeCoreException { Date date = new Date(); IAtsLogItem item = getTestLogItem(date, user); item.setMsg("new msg"); Assert.assertEquals("new msg", item.getMsg()); item.setState("Implement"); Assert.assertEquals("Implement", item.getState()); item.setUserId("asdf"); Assert.assertEquals("asdf", item.getUserId()); item.setType(LogType.Note); Assert.assertEquals(LogType.Note, item.getType()); Calendar cal = Calendar.getInstance(); cal.set(2011, 10, 1); Date newDate = cal.getTime(); item.setDate(newDate); Assert.assertNotEquals(date, item.getDate()); Assert.assertEquals(newDate, item.getDate()); }