List of usage examples for org.hibernate Session save
Serializable save(Object object);
From source file:au.edu.uts.eng.remotelabs.schedserver.bookings.intf.tests.BookingsServiceTester.java
License:Open Source License
/** * Test method for {@link BookingsService#getBookings(types.GetBookings)}. */// ww w . j a v a 2s. c o m public void testGetBookingsResourceID() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); UserClass uclass1 = new UserClass(); uclass1.setName("booktestclass"); uclass1.setActive(true); uclass1.setQueuable(false); uclass1.setBookable(true); uclass1.setTimeHorizon(1000); ses.save(uclass1); User us1 = new User(); us1.setName("bktestuser1"); us1.setNamespace("BKNS"); us1.setPersona("USER"); ses.save(us1); User us2 = new User(); us2.setName("bktestuser2"); us2.setNamespace("BKNS"); us2.setPersona("USER"); ses.save(us2); RigType rigType1 = new RigType("booktestrigtype", 300, false); ses.save(rigType1); RigType rigType2 = new RigType("booktestrigtype2", 300, false); ses.save(rigType2); ResourcePermission perm1 = new ResourcePermission(); perm1.setUserClass(uclass1); perm1.setType("TYPE"); perm1.setSessionDuration(3600); perm1.setQueueActivityTimeout(300); perm1.setAllowedExtensions((short) 10); perm1.setSessionActivityTimeout(300); perm1.setExtensionDuration(300); perm1.setMaximumBookings(10); perm1.setRigType(rigType1); perm1.setStartTime(new Date()); perm1.setExpiryTime(new Date()); perm1.setDisplayName("bookperm"); ses.save(perm1); ResourcePermission perm2 = new ResourcePermission(); perm2.setUserClass(uclass1); perm2.setType("TYPE"); perm2.setSessionDuration(3600); perm2.setQueueActivityTimeout(300); perm2.setAllowedExtensions((short) 10); perm2.setSessionActivityTimeout(300); perm2.setExtensionDuration(300); perm2.setMaximumBookings(10); perm2.setRigType(rigType2); perm2.setStartTime(new Date()); perm2.setExpiryTime(new Date()); perm2.setDisplayName("bookperm"); ses.save(perm2); Bookings bk1 = new Bookings(); bk1.setActive(true); bk1.setDuration(3600); Date start = new Date(); bk1.setStartTime(start); Date end = new Date(System.currentTimeMillis() + 3600 * 1000); bk1.setEndTime(end); bk1.setResourcePermission(perm1); bk1.setResourceType("TYPE"); bk1.setRigType(rigType1); bk1.setUser(us1); bk1.setUserName(us1.getName()); bk1.setUserNamespace(us1.getNamespace()); bk1.setCodeReference("/foo/bar"); ses.save(bk1); Bookings bk2 = new Bookings(); bk2.setActive(false); bk2.setCancelReason("Test cancel."); bk2.setDuration(3600); Date startLt = new Date(start.getTime() + 100000); bk2.setStartTime(startLt); bk2.setEndTime(end); bk2.setResourcePermission(perm1); bk2.setResourceType("TYPE"); bk2.setRigType(rigType1); bk2.setUser(us1); bk2.setUserName(us1.getName()); bk2.setUserNamespace(us1.getNamespace()); bk2.setCodeReference("/foo/bar"); ses.save(bk2); Bookings bk3 = new Bookings(); bk3.setActive(true); bk3.setDuration(3600); bk3.setStartTime(start); bk3.setEndTime(end); bk3.setResourcePermission(perm1); bk3.setResourceType("TYPE"); bk3.setRigType(rigType1); bk3.setUser(us1); bk3.setUserName(us1.getName()); bk3.setUserNamespace(us1.getNamespace()); bk3.setCodeReference("/foo/bar"); ses.save(bk3); Bookings bk4 = new Bookings(); bk4.setActive(true); bk4.setDuration(3600); bk4.setStartTime(start); bk4.setEndTime(end); bk4.setResourcePermission(perm1); bk4.setResourceType("TYPE"); bk4.setRigType(rigType1); bk4.setUser(us2); bk4.setUserName(us2.getName()); bk4.setUserNamespace(us2.getNamespace()); bk4.setCodeReference("/foo/bar"); ses.save(bk4); Bookings bk5 = new Bookings(); bk5.setActive(false); bk5.setDuration(3600); bk5.setStartTime(start); bk5.setEndTime(end); bk5.setResourcePermission(perm2); bk5.setResourceType("TYPE"); bk5.setRigType(rigType2); bk5.setUser(us2); bk5.setUserName(us2.getName()); bk5.setUserNamespace(us2.getNamespace()); bk5.setCodeReference("/foo/bar"); ses.save(bk5); Bookings bk6 = new Bookings(); bk6.setActive(true); bk6.setDuration(3600); bk6.setStartTime(start); bk6.setEndTime(end); bk6.setResourcePermission(perm2); bk6.setResourceType("TYPE"); bk6.setRigType(rigType2); bk6.setUser(us2); bk6.setUserName(us2.getName()); bk6.setUserNamespace(us2.getNamespace()); bk6.setCodeReference("/foo/bar"); ses.save(bk6); ses.getTransaction().commit(); GetBookings request = new GetBookings(); BookingsRequestType reqTy = new BookingsRequestType(); request.setGetBookings(reqTy); ResourceIDType rid = new ResourceIDType(); rid.setType("TYPE"); rid.setResourceID(rigType1.getId().intValue()); reqTy.setResourceID(rid); reqTy.setShowCancelled(true); reqTy.setShowFinished(true); GetBookingsResponse response = this.service.getBookings(request); ses.beginTransaction(); ses.delete(bk6); ses.delete(bk5); ses.delete(bk4); ses.delete(bk3); ses.delete(bk2); ses.delete(bk1); ses.delete(perm1); ses.delete(perm2); ses.delete(rigType1); ses.delete(rigType2); ses.delete(us2); ses.delete(us1); ses.delete(uclass1); ses.getTransaction().commit(); assertNotNull(response); BookingListType bklist = response.getGetBookingsResponse(); assertNotNull(bklist); BookingType[] bks = bklist.getBookings(); assertEquals(4, bks.length); }
From source file:au.edu.uts.eng.remotelabs.schedserver.bookings.intf.tests.BookingsServiceTester.java
License:Open Source License
/** * Test method for {@link BookingsService#getBookings(types.GetBookings)}. *//* w w w.jav a2s . c om*/ public void testGetBookingsResourceName() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); UserClass uclass1 = new UserClass(); uclass1.setName("booktestclass"); uclass1.setActive(true); uclass1.setQueuable(false); uclass1.setBookable(true); uclass1.setTimeHorizon(1000); ses.save(uclass1); User us1 = new User(); us1.setName("bktestuser1"); us1.setNamespace("BKNS"); us1.setPersona("USER"); ses.save(us1); User us2 = new User(); us2.setName("bktestuser2"); us2.setNamespace("BKNS"); us2.setPersona("USER"); ses.save(us2); RigType rigType1 = new RigType("booktestrigtype", 300, false); ses.save(rigType1); RigType rigType2 = new RigType("booktestrigtype2", 300, false); ses.save(rigType2); ResourcePermission perm1 = new ResourcePermission(); perm1.setUserClass(uclass1); perm1.setType("TYPE"); perm1.setSessionDuration(3600); perm1.setQueueActivityTimeout(300); perm1.setAllowedExtensions((short) 10); perm1.setSessionActivityTimeout(300); perm1.setExtensionDuration(300); perm1.setMaximumBookings(10); perm1.setRigType(rigType1); perm1.setStartTime(new Date()); perm1.setExpiryTime(new Date()); perm1.setDisplayName("bookperm"); ses.save(perm1); ResourcePermission perm2 = new ResourcePermission(); perm2.setUserClass(uclass1); perm2.setType("TYPE"); perm2.setSessionDuration(3600); perm2.setQueueActivityTimeout(300); perm2.setAllowedExtensions((short) 10); perm2.setSessionActivityTimeout(300); perm2.setExtensionDuration(300); perm2.setMaximumBookings(10); perm2.setRigType(rigType2); perm2.setStartTime(new Date()); perm2.setExpiryTime(new Date()); perm2.setDisplayName("bookperm"); ses.save(perm2); Bookings bk1 = new Bookings(); bk1.setActive(true); bk1.setDuration(3600); Date start = new Date(); bk1.setStartTime(start); Date end = new Date(System.currentTimeMillis() + 3600 * 1000); bk1.setEndTime(end); bk1.setResourcePermission(perm1); bk1.setResourceType("TYPE"); bk1.setRigType(rigType1); bk1.setUser(us1); bk1.setUserName(us1.getName()); bk1.setUserNamespace(us1.getNamespace()); bk1.setCodeReference("/foo/bar"); ses.save(bk1); Bookings bk2 = new Bookings(); bk2.setActive(false); bk2.setCancelReason("Test cancel."); bk2.setDuration(3600); Date startLt = new Date(start.getTime() + 100000); bk2.setStartTime(startLt); bk2.setEndTime(end); bk2.setResourcePermission(perm1); bk2.setResourceType("TYPE"); bk2.setRigType(rigType1); bk2.setUser(us1); bk2.setUserName(us1.getName()); bk2.setUserNamespace(us1.getNamespace()); bk2.setCodeReference("/foo/bar"); ses.save(bk2); Bookings bk3 = new Bookings(); bk3.setActive(true); bk3.setDuration(3600); bk3.setStartTime(start); bk3.setEndTime(end); bk3.setResourcePermission(perm2); bk3.setResourceType("TYPE"); bk3.setRigType(rigType1); bk3.setUser(us1); bk3.setUserName(us1.getName()); bk3.setUserNamespace(us1.getNamespace()); bk3.setCodeReference("/foo/bar"); ses.save(bk3); Bookings bk4 = new Bookings(); bk4.setActive(true); bk4.setDuration(3600); bk4.setStartTime(start); bk4.setEndTime(end); bk4.setResourcePermission(perm1); bk4.setResourceType("TYPE"); bk4.setRigType(rigType1); bk4.setUser(us2); bk4.setUserName(us2.getName()); bk4.setUserNamespace(us2.getNamespace()); bk4.setCodeReference("/foo/bar"); ses.save(bk4); Bookings bk5 = new Bookings(); bk5.setActive(false); bk5.setDuration(3600); bk5.setStartTime(start); bk5.setEndTime(end); bk5.setResourcePermission(perm2); bk5.setResourceType("TYPE"); bk5.setRigType(rigType2); bk5.setUser(us2); bk5.setUserName(us2.getName()); bk5.setUserNamespace(us2.getNamespace()); bk5.setCodeReference("/foo/bar"); ses.save(bk5); Bookings bk6 = new Bookings(); bk6.setActive(true); bk6.setDuration(3600); bk6.setStartTime(new Date(start.getTime() + 100)); bk6.setEndTime(end); bk6.setResourcePermission(perm2); bk6.setResourceType("TYPE"); bk6.setRigType(rigType2); bk6.setUser(us2); bk6.setUserName(us2.getName()); bk6.setUserNamespace(us2.getNamespace()); bk6.setCodeReference("/foo/bar"); ses.save(bk6); ses.getTransaction().commit(); GetBookings request = new GetBookings(); BookingsRequestType reqTy = new BookingsRequestType(); request.setGetBookings(reqTy); ResourceIDType rid = new ResourceIDType(); rid.setType("TYPE"); rid.setResourceName(rigType2.getName()); reqTy.setResourceID(rid); reqTy.setShowCancelled(true); reqTy.setShowFinished(true); GetBookingsResponse response = this.service.getBookings(request); ses.beginTransaction(); ses.delete(bk6); ses.delete(bk5); ses.delete(bk4); ses.delete(bk3); ses.delete(bk2); ses.delete(bk1); ses.delete(perm1); ses.delete(perm2); ses.delete(rigType1); ses.delete(rigType2); ses.delete(us2); ses.delete(us1); ses.delete(uclass1); ses.getTransaction().commit(); assertNotNull(response); BookingListType bklist = response.getGetBookingsResponse(); assertNotNull(bklist); BookingType[] bks = bklist.getBookings(); assertEquals(2, bks.length); BookingType bt = bks[0]; assertNotNull(bt); assertEquals(bt.getBookingID(), bk5.getId().intValue()); bt = bks[1]; assertNotNull(bt); assertEquals(bt.getBookingID(), bk6.getId().intValue()); }
From source file:au.edu.uts.eng.remotelabs.schedserver.bookings.intf.tests.BookingsServiceTester.java
License:Open Source License
/** * Test method for {@link BookingsService#getBookings(types.GetBookings)}. *///from w ww .j a v a2 s.c om public void testGetBookingsResourceRig() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); UserClass uclass1 = new UserClass(); uclass1.setName("booktestclass"); uclass1.setActive(true); uclass1.setQueuable(false); uclass1.setBookable(true); uclass1.setTimeHorizon(1000); ses.save(uclass1); User us1 = new User(); us1.setName("bktestuser1"); us1.setNamespace("BKNS"); us1.setPersona("USER"); ses.save(us1); User us2 = new User(); us2.setName("bktestuser2"); us2.setNamespace("BKNS"); us2.setPersona("USER"); ses.save(us2); RigType rigType1 = new RigType("booktestrigtype", 300, false); ses.save(rigType1); RigType rigType2 = new RigType("booktestrigtype2", 300, false); ses.save(rigType2); RigCapabilities caps = new RigCapabilities("a,b,c,d"); ses.save(caps); Rig rig = new Rig(); rig.setName("booktestrig"); rig.setLastUpdateTimestamp(new Date()); rig.setRigCapabilities(caps); rig.setRigType(rigType1); ses.save(rig); ResourcePermission perm1 = new ResourcePermission(); perm1.setUserClass(uclass1); perm1.setType("TYPE"); perm1.setSessionDuration(3600); perm1.setQueueActivityTimeout(300); perm1.setAllowedExtensions((short) 10); perm1.setSessionActivityTimeout(300); perm1.setExtensionDuration(300); perm1.setMaximumBookings(10); perm1.setRigType(rigType1); perm1.setStartTime(new Date()); perm1.setExpiryTime(new Date()); perm1.setDisplayName("bookperm"); ses.save(perm1); ResourcePermission perm2 = new ResourcePermission(); perm2.setUserClass(uclass1); perm2.setType("RIG"); perm2.setSessionDuration(3600); perm2.setQueueActivityTimeout(300); perm2.setAllowedExtensions((short) 10); perm2.setSessionActivityTimeout(300); perm2.setExtensionDuration(300); perm2.setMaximumBookings(10); perm2.setRig(rig); perm2.setStartTime(new Date()); perm2.setExpiryTime(new Date()); perm2.setDisplayName("bookperm"); ses.save(perm2); Bookings bk1 = new Bookings(); bk1.setActive(true); bk1.setDuration(3600); Date start = new Date(); bk1.setStartTime(start); Date end = new Date(System.currentTimeMillis() + 3600 * 1000); bk1.setEndTime(end); bk1.setResourcePermission(perm1); bk1.setResourceType("TYPE"); bk1.setRigType(rigType1); bk1.setUser(us1); bk1.setUserName(us1.getName()); bk1.setUserNamespace(us1.getNamespace()); bk1.setCodeReference("/foo/bar"); ses.save(bk1); Bookings bk2 = new Bookings(); bk2.setActive(false); bk2.setCancelReason("Test cancel."); bk2.setDuration(3600); Date startLt = new Date(start.getTime() + 100000); bk2.setStartTime(startLt); bk2.setEndTime(end); bk2.setResourcePermission(perm1); bk2.setResourceType("TYPE"); bk2.setRigType(rigType1); bk2.setUser(us1); bk2.setUserName(us1.getName()); bk2.setUserNamespace(us1.getNamespace()); bk2.setCodeReference("/foo/bar"); ses.save(bk2); Bookings bk3 = new Bookings(); bk3.setActive(true); bk3.setDuration(3600); bk3.setStartTime(start); bk3.setEndTime(end); bk3.setResourcePermission(perm2); bk3.setResourceType("TYPE"); bk3.setRigType(rigType1); bk3.setUser(us1); bk3.setUserName(us1.getName()); bk3.setUserNamespace(us1.getNamespace()); bk3.setCodeReference("/foo/bar"); ses.save(bk3); Bookings bk4 = new Bookings(); bk4.setActive(true); bk4.setDuration(3600); bk4.setStartTime(start); bk4.setEndTime(end); bk4.setResourcePermission(perm1); bk4.setResourceType("TYPE"); bk4.setRigType(rigType1); bk4.setUser(us2); bk4.setUserName(us2.getName()); bk4.setUserNamespace(us2.getNamespace()); bk4.setCodeReference("/foo/bar"); ses.save(bk4); Bookings bk5 = new Bookings(); bk5.setActive(false); bk5.setDuration(3600); bk5.setStartTime(start); bk5.setEndTime(end); bk5.setResourcePermission(perm1); bk5.setResourceType("TYPE"); bk5.setRigType(rigType1); bk5.setUser(us2); bk5.setUserName(us2.getName()); bk5.setUserNamespace(us2.getNamespace()); bk5.setCodeReference("/foo/bar"); ses.save(bk5); Bookings bk6 = new Bookings(); bk6.setActive(true); bk6.setDuration(3600); bk6.setStartTime(new Date(start.getTime() + 100)); bk6.setEndTime(end); bk6.setResourcePermission(perm2); bk6.setResourceType("RIG"); bk6.setRig(rig); bk6.setUser(us2); bk6.setUserName(us2.getName()); bk6.setUserNamespace(us2.getNamespace()); bk6.setCodeReference("/foo/bar"); ses.save(bk6); ses.getTransaction().commit(); GetBookings request = new GetBookings(); BookingsRequestType reqTy = new BookingsRequestType(); request.setGetBookings(reqTy); ResourceIDType rid = new ResourceIDType(); rid.setType("RIG"); rid.setResourceName(rig.getName()); reqTy.setResourceID(rid); reqTy.setShowCancelled(true); reqTy.setShowFinished(true); GetBookingsResponse response = this.service.getBookings(request); ses.beginTransaction(); ses.delete(bk6); ses.delete(bk5); ses.delete(bk4); ses.delete(bk3); ses.delete(bk2); ses.delete(bk1); ses.delete(perm1); ses.delete(perm2); ses.delete(rig); ses.delete(caps); ses.delete(rigType1); ses.delete(rigType2); ses.delete(us2); ses.delete(us1); ses.delete(uclass1); ses.getTransaction().commit(); assertNotNull(response); BookingListType bklist = response.getGetBookingsResponse(); assertNotNull(bklist); BookingType[] bks = bklist.getBookings(); assertEquals(1, bks.length); BookingType bt = bks[0]; assertNotNull(bt); assertEquals(bt.getBookingID(), bk6.getId().intValue()); }
From source file:au.edu.uts.eng.remotelabs.schedserver.bookings.intf.tests.BookingsServiceTester.java
License:Open Source License
/** * Test method for {@link BookingsService#getBookings(types.GetBookings)}. *//*w w w.j ava 2 s .com*/ public void testGetBookingsResourceCaps() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); UserClass uclass1 = new UserClass(); uclass1.setName("booktestclass"); uclass1.setActive(true); uclass1.setQueuable(false); uclass1.setBookable(true); uclass1.setTimeHorizon(1000); ses.save(uclass1); User us1 = new User(); us1.setName("bktestuser1"); us1.setNamespace("BKNS"); us1.setPersona("USER"); ses.save(us1); User us2 = new User(); us2.setName("bktestuser2"); us2.setNamespace("BKNS"); us2.setPersona("USER"); ses.save(us2); RigType rigType1 = new RigType("booktestrigtype", 300, false); ses.save(rigType1); RequestCapabilities rcaps = new RequestCapabilities("a,b,c,d"); ses.save(rcaps); ResourcePermission perm1 = new ResourcePermission(); perm1.setUserClass(uclass1); perm1.setType("TYPE"); perm1.setSessionDuration(3600); perm1.setQueueActivityTimeout(300); perm1.setAllowedExtensions((short) 10); perm1.setSessionActivityTimeout(300); perm1.setExtensionDuration(300); perm1.setMaximumBookings(10); perm1.setRigType(rigType1); perm1.setStartTime(new Date()); perm1.setExpiryTime(new Date()); perm1.setDisplayName("bookperm"); ses.save(perm1); ResourcePermission perm2 = new ResourcePermission(); perm2.setUserClass(uclass1); perm2.setType("CAPABILITY"); perm2.setSessionDuration(3600); perm2.setQueueActivityTimeout(300); perm2.setAllowedExtensions((short) 10); perm2.setSessionActivityTimeout(300); perm2.setExtensionDuration(300); perm2.setMaximumBookings(10); perm2.setRequestCapabilities(rcaps); perm2.setStartTime(new Date()); perm2.setExpiryTime(new Date()); perm2.setDisplayName("bookperm"); ses.save(perm2); Bookings bk1 = new Bookings(); bk1.setActive(true); bk1.setDuration(3600); Date start = new Date(); bk1.setStartTime(start); Date end = new Date(System.currentTimeMillis() + 3600 * 1000); bk1.setEndTime(end); bk1.setResourcePermission(perm1); bk1.setResourceType("TYPE"); bk1.setRigType(rigType1); bk1.setUser(us1); bk1.setUserName(us1.getName()); bk1.setUserNamespace(us1.getNamespace()); bk1.setCodeReference("/foo/bar"); ses.save(bk1); Bookings bk2 = new Bookings(); bk2.setActive(false); bk2.setCancelReason("Test cancel."); bk2.setDuration(3600); Date startLt = new Date(start.getTime() + 100000); bk2.setStartTime(startLt); bk2.setEndTime(end); bk2.setResourcePermission(perm1); bk2.setResourceType("TYPE"); bk2.setRigType(rigType1); bk2.setUser(us1); bk2.setUserName(us1.getName()); bk2.setUserNamespace(us1.getNamespace()); bk2.setCodeReference("/foo/bar"); ses.save(bk2); Bookings bk3 = new Bookings(); bk3.setActive(true); bk3.setDuration(3600); bk3.setStartTime(start); bk3.setEndTime(end); bk3.setResourcePermission(perm2); bk3.setResourceType("TYPE"); bk3.setRigType(rigType1); bk3.setUser(us1); bk3.setUserName(us1.getName()); bk3.setUserNamespace(us1.getNamespace()); bk3.setCodeReference("/foo/bar"); ses.save(bk3); Bookings bk4 = new Bookings(); bk4.setActive(true); bk4.setDuration(3600); bk4.setStartTime(start); bk4.setEndTime(end); bk4.setResourcePermission(perm1); bk4.setResourceType("TYPE"); bk4.setRigType(rigType1); bk4.setUser(us2); bk4.setUserName(us2.getName()); bk4.setUserNamespace(us2.getNamespace()); bk4.setCodeReference("/foo/bar"); ses.save(bk4); Bookings bk5 = new Bookings(); bk5.setActive(false); bk5.setDuration(3600); bk5.setStartTime(start); bk5.setEndTime(end); bk5.setResourcePermission(perm2); bk5.setResourceType("CAPABILITY"); bk5.setRequestCapabilities(rcaps); bk5.setUser(us2); bk5.setUserName(us2.getName()); bk5.setUserNamespace(us2.getNamespace()); bk5.setCodeReference("/foo/bar"); ses.save(bk5); Bookings bk6 = new Bookings(); bk6.setActive(true); bk6.setDuration(3600); bk6.setStartTime(new Date(start.getTime() + 100)); bk6.setEndTime(end); bk6.setResourcePermission(perm1); bk6.setResourceType("TYPE"); bk6.setRigType(rigType1); bk6.setUser(us2); bk6.setUserName(us2.getName()); bk6.setUserNamespace(us2.getNamespace()); bk6.setCodeReference("/foo/bar"); ses.save(bk6); ses.getTransaction().commit(); GetBookings request = new GetBookings(); BookingsRequestType reqTy = new BookingsRequestType(); request.setGetBookings(reqTy); ResourceIDType rid = new ResourceIDType(); rid.setType("CAPABILITY"); rid.setResourceName(rcaps.getCapabilities()); reqTy.setResourceID(rid); reqTy.setShowCancelled(true); reqTy.setShowFinished(true); GetBookingsResponse response = this.service.getBookings(request); ses.beginTransaction(); ses.delete(bk6); ses.delete(bk5); ses.delete(bk4); ses.delete(bk3); ses.delete(bk2); ses.delete(bk1); ses.delete(perm1); ses.delete(perm2); ses.delete(rigType1); ses.delete(rcaps); ses.delete(us2); ses.delete(us1); ses.delete(uclass1); ses.getTransaction().commit(); assertNotNull(response); BookingListType bklist = response.getGetBookingsResponse(); assertNotNull(bklist); BookingType[] bks = bklist.getBookings(); assertEquals(1, bks.length); BookingType bt = bks[0]; assertNotNull(bt); assertEquals(bt.getBookingID(), bk5.getId().intValue()); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.GenericDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.GenericDao#get(java.lang.Class, java.io.Serializable)}. *///from w ww .j a v a2s.com public void testGet() { String key = "get_test_key"; String val = "get_test_val"; Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); Config c = new Config(key, val); ses.save(c); ses.getTransaction().commit(); ses.close(); Config got = this.dao.get(c.getId()); assertNotNull(got); assertEquals(c.getId(), got.getId()); assertEquals(c.getKey(), got.getKey()); assertEquals(c.getValue(), got.getValue()); this.dao.delete(got); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.GenericDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.GenericDao#delete(java.lang.Object)}. *//*w w w. j av a 2 s. c o m*/ public void testDelete() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); Serializable id = ses.save(new Config("delete_conf_key", "delete_conf_val")); ses.getTransaction().commit(); ses.close(); ses = DataAccessActivator.getNewSession(); assertNotNull(ses.get(Config.class, id)); ses.close(); this.dao.delete(this.dao.get(id)); ses = DataAccessActivator.getNewSession(); assertNull(ses.get(Config.class, id)); ses.close(); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.GenericDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.GenericDao#delete(java.lang.Object)}. *///w w w . jav a2s . c o m public void testDeleteId() { Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); Serializable id = ses.save(new Config("delete_conf_key", "delete_conf_val")); ses.getTransaction().commit(); ses.close(); ses = DataAccessActivator.getNewSession(); assertNotNull(ses.get(Config.class, id)); ses.close(); this.dao.delete(id); ses = DataAccessActivator.getNewSession(); assertNull(ses.get(Config.class, id)); ses.close(); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.RequestCapabilitiesDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.RigCapabilitiesDao#findCapabilites(java.lang.String)}. *///from w w w. j a v a2 s. com @Test public void testFindCapabilites() { Session ses = DataAccessActivator.getNewSession(); RequestCapabilities caps = new RequestCapabilities("a,b,c,d,e,f"); ses.beginTransaction(); ses.save(caps); ses.getTransaction().commit(); ses.close(); RequestCapabilities ld = this.dao.findCapabilites("a,b,c,d,e,f"); assertNotNull(ld); assertEquals(caps.getId(), ld.getId()); this.dao.delete(ld); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.RigCapabilitiesDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.RigCapabilitiesDao#findCapabilites(java.lang.String)}. *//*from w w w . j a v a 2 s . c o m*/ @Test public void testFindCapabilites() { Session ses = DataAccessActivator.getNewSession(); RigCapabilities caps = new RigCapabilities("a,b,c,d,e,f"); ses.beginTransaction(); ses.save(caps); ses.getTransaction().commit(); ses.close(); RigCapabilities ld = this.dao.findCapabilites("a,b,c,d,e,f"); assertNotNull(ld); assertEquals(caps.getId(), ld.getId()); this.dao.delete(ld); }
From source file:au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.tests.RigDaoTester.java
License:Open Source License
/** * Test method for {@link au.edu.uts.eng.remotelabs.schedserver.dataaccess.dao.RigDao#findByName(java.lang.String)}. */// w w w . j a v a2 s . c o m @Test public void testFindByName() { /* Add a rig. */ Session ses = DataAccessActivator.getNewSession(); ses.beginTransaction(); RigType type = new RigType(); type.setName("rig_test"); type.setLogoffGraceDuration(600); ses.save(type); RigCapabilities caps = new RigCapabilities("a,b,c,d,e,f"); ses.save(caps); Rig rig = new Rig(); rig.setName("rig_name_test"); rig.setRigType(type); rig.setContactUrl("http://url"); rig.setRigCapabilities(caps); Timestamp ts = new Timestamp(System.currentTimeMillis()); ts.setNanos(0); // Need to trunc time as nanoseconds aren't stored in the DB. rig.setLastUpdateTimestamp(ts); rig.setManaged(false); rig.setMeta("iLabs"); rig.setOfflineReason("Tomorrows problem"); ses.save(rig); ses.getTransaction().commit(); ses.close(); /* Find the rig. */ Rig fRig = this.dao.findByName("rig_name_test"); assertNotNull(fRig); assertEquals(rig.getId(), fRig.getId()); assertEquals(rig.getContactUrl(), fRig.getContactUrl()); assertEquals(fRig.getLastUpdateTimestamp(), rig.getLastUpdateTimestamp()); assertEquals(rig.getRigType().getName(), fRig.getRigType().getName()); assertEquals(rig.getRigCapabilities().getCapabilities(), fRig.getRigCapabilities().getCapabilities()); assertEquals(rig.isManaged(), fRig.isManaged()); assertEquals(rig.getMeta(), fRig.getMeta()); assertEquals(rig.getOfflineReason(), fRig.getOfflineReason()); /* Delete all. */ this.dao.delete(fRig); ses = this.dao.getSession(); ses.beginTransaction(); ses.delete(fRig.getRigCapabilities()); ses.delete(fRig.getRigType()); ses.getTransaction().commit(); }