Demo entry 6364815

java

   

Submitted by anonymous on May 17, 2017 at 07:00
Language: Java. Code size: 1.4 kB.

@Test
	public void testSaveAnnouncementKeyNull() {
		System.out.println("testSaveAnnouncementKeyNull:");
		Announcement announcement = new Announcement();
		announcement.setAnnouncementId(null);//key null
		announcement.setContent("通知");
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());
		announcement.setCreateTime(timestamp);
		//announcement.setState(new Integer(1));
		assertNull(null, announcement.getAnnouncementId());
		Announcement result = announcementServiceImpl
				.saveOrUpdate(announcement);
		assertNotNull(result);
		System.out.println(result);
		assertEquals(
				announcementServiceImpl.getLastInsertId(),
				result.getAnnouncementId());
	}

	@Test
	public void testSaveAnnouncementExist() {
		init();
		System.out.println("testSaveAnnouncementExist:");
		Announcement announcement = new Announcement();
		announcement.setAnnouncementId(new Integer(announcementServiceImpl.getLastInsertId()));// existed
		announcement.setContent("通知");
		Timestamp timestamp = new Timestamp(System.currentTimeMillis());
		announcement.setCreateTime(timestamp);
		//announcement.setState(new Integer(1));
		Announcement result = announcementServiceImpl
				.saveOrUpdate(announcement);
		assertNotNull(result);
		System.out.println(result);
		assertEquals(announcementServiceImpl.getLastInsertId(), result.getAnnouncementId());
	}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).