use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method testHibernateNoUserIdParamWillSaveNewUser.
@Test
public void testHibernateNoUserIdParamWillSaveNewUser() {
String email = "test1";
HttpDummyRequest req = Requests.createPostRequest("/testmerge", "user.email", email, "user.name", "blah1", "user.firstName", "blah2");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
UserTestDbo user2 = loadByEmail(email);
//name changed
Assert.assertEquals("blah1", user2.getName());
//firstname changed
Assert.assertEquals("blah2", user2.getFirstName());
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method loadByEmail.
private UserTestDbo loadByEmail(String email) {
EntityManagerFactory factory = Persistence.createEntityManagerFactory(HibernateAppMeta.PERSISTENCE_TEST_UNIT);
EntityManager mgr = factory.createEntityManager();
EntityTransaction tx = mgr.getTransaction();
tx.begin();
UserTestDbo user = UserTestDbo.findByEmailId(mgr, email);
tx.commit();
return user;
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class CrudTestController method postDeleteUser.
public Redirect postDeleteUser(Integer id) {
UserTestDbo user = Em.get().getReference(UserTestDbo.class, id);
Em.get().remove(user);
Em.get().flush();
Current.flash().setMessage("User " + user.getFirstName() + " " + user.getLastName() + " was deleted");
return Actions.redirect(HibernateRouteId.LIST_USERS);
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestFlashAndSelect method loadDataInDb.
public static UserTestDbo loadDataInDb() {
String email = "dean2@sync.xsoftware.biz";
//populate database....
EntityManagerFactory factory = Persistence.createEntityManagerFactory(HibernateAppMeta.PERSISTENCE_TEST_UNIT);
EntityManager mgr = factory.createEntityManager();
EntityTransaction tx = mgr.getTransaction();
tx.begin();
UserTestDbo manager = new UserTestDbo();
manager.setEmail("asdf@asf.com");
manager.setName("somadsf");
UserTestDbo user = new UserTestDbo();
user.setEmail(email);
user.setName("SomeName");
user.setFirstName("Dean");
user.setLastName("Hill");
user.setLevelOfEducation(LevelEducation.KINDERGARTEN);
user.setManager(manager);
UserRoleDbo role1 = new UserRoleDbo(user, Role.DELINQUINT);
UserRoleDbo role2 = new UserRoleDbo(user, Role.BADASS);
mgr.persist(manager);
mgr.persist(user);
mgr.persist(role1);
mgr.persist(role2);
mgr.flush();
tx.commit();
return user;
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method testHibernateNoUserIdWillSaveNewUser.
@Test
public void testHibernateNoUserIdWillSaveNewUser() {
String email = "test2";
HttpDummyRequest req = Requests.createPostRequest("/testmerge", "user.id", "", "user.email", email, "user.name", "blah1", "user.firstName", "blah2", "user.levelOfEducation", LevelEducation.COLLEGE.getDbCode() + "");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
UserTestDbo user2 = loadByEmail(email);
//name changed
Assert.assertEquals("blah1", user2.getName());
//firstname changed
Assert.assertEquals("blah2", user2.getFirstName());
Assert.assertEquals(LevelEducation.COLLEGE, user2.getLevelOfEducation());
}
Aggregations