protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) { if (orgLabor instanceof OrgLaborImpl) { return orgLabor; } OrgLaborImpl orgLaborImpl = new OrgLaborImpl(); orgLaborImpl.setNew(orgLabor.isNew()); orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey()); orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId()); orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId()); orgLaborImpl.setTypeId(orgLabor.getTypeId()); orgLaborImpl.setSunOpen(orgLabor.getSunOpen()); orgLaborImpl.setSunClose(orgLabor.getSunClose()); orgLaborImpl.setMonOpen(orgLabor.getMonOpen()); orgLaborImpl.setMonClose(orgLabor.getMonClose()); orgLaborImpl.setTueOpen(orgLabor.getTueOpen()); orgLaborImpl.setTueClose(orgLabor.getTueClose()); orgLaborImpl.setWedOpen(orgLabor.getWedOpen()); orgLaborImpl.setWedClose(orgLabor.getWedClose()); orgLaborImpl.setThuOpen(orgLabor.getThuOpen()); orgLaborImpl.setThuClose(orgLabor.getThuClose()); orgLaborImpl.setFriOpen(orgLabor.getFriOpen()); orgLaborImpl.setFriClose(orgLabor.getFriClose()); orgLaborImpl.setSatOpen(orgLabor.getSatOpen()); orgLaborImpl.setSatClose(orgLabor.getSatClose()); return orgLaborImpl; }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { OrgLabor newOrgLabor = addOrgLabor(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(OrgLabor.class, _dynamicQueryClassLoader); dynamicQuery.add(RestrictionsFactoryUtil.eq("orgLaborId", newOrgLabor.getOrgLaborId())); List<OrgLabor> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); OrgLabor existingOrgLabor = result.get(0); Assert.assertEquals(existingOrgLabor, newOrgLabor); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { OrgLabor newOrgLabor = addOrgLabor(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(OrgLabor.class, _dynamicQueryClassLoader); dynamicQuery.setProjection(ProjectionFactoryUtil.property("orgLaborId")); Object newOrgLaborId = newOrgLabor.getOrgLaborId(); dynamicQuery.add(RestrictionsFactoryUtil.in("orgLaborId", new Object[] {newOrgLaborId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingOrgLaborId = result.get(0); Assert.assertEquals(existingOrgLaborId, newOrgLaborId); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); OrgLabor newOrgLabor = _persistence.create(pk); newOrgLabor.setMvccVersion(RandomTestUtil.nextLong()); newOrgLabor.setCompanyId(RandomTestUtil.nextLong()); newOrgLabor.setOrganizationId(RandomTestUtil.nextLong()); newOrgLabor.setTypeId(RandomTestUtil.nextLong()); newOrgLabor.setSunOpen(RandomTestUtil.nextInt()); newOrgLabor.setSunClose(RandomTestUtil.nextInt()); newOrgLabor.setMonOpen(RandomTestUtil.nextInt()); newOrgLabor.setMonClose(RandomTestUtil.nextInt()); newOrgLabor.setTueOpen(RandomTestUtil.nextInt()); newOrgLabor.setTueClose(RandomTestUtil.nextInt()); newOrgLabor.setWedOpen(RandomTestUtil.nextInt()); newOrgLabor.setWedClose(RandomTestUtil.nextInt()); newOrgLabor.setThuOpen(RandomTestUtil.nextInt()); newOrgLabor.setThuClose(RandomTestUtil.nextInt()); newOrgLabor.setFriOpen(RandomTestUtil.nextInt()); newOrgLabor.setFriClose(RandomTestUtil.nextInt()); newOrgLabor.setSatOpen(RandomTestUtil.nextInt()); newOrgLabor.setSatClose(RandomTestUtil.nextInt()); _orgLabors.add(_persistence.update(newOrgLabor)); OrgLabor existingOrgLabor = _persistence.findByPrimaryKey(newOrgLabor.getPrimaryKey()); Assert.assertEquals(existingOrgLabor.getMvccVersion(), newOrgLabor.getMvccVersion()); Assert.assertEquals(existingOrgLabor.getOrgLaborId(), newOrgLabor.getOrgLaborId()); Assert.assertEquals(existingOrgLabor.getCompanyId(), newOrgLabor.getCompanyId()); Assert.assertEquals(existingOrgLabor.getOrganizationId(), newOrgLabor.getOrganizationId()); Assert.assertEquals(existingOrgLabor.getTypeId(), newOrgLabor.getTypeId()); Assert.assertEquals(existingOrgLabor.getSunOpen(), newOrgLabor.getSunOpen()); Assert.assertEquals(existingOrgLabor.getSunClose(), newOrgLabor.getSunClose()); Assert.assertEquals(existingOrgLabor.getMonOpen(), newOrgLabor.getMonOpen()); Assert.assertEquals(existingOrgLabor.getMonClose(), newOrgLabor.getMonClose()); Assert.assertEquals(existingOrgLabor.getTueOpen(), newOrgLabor.getTueOpen()); Assert.assertEquals(existingOrgLabor.getTueClose(), newOrgLabor.getTueClose()); Assert.assertEquals(existingOrgLabor.getWedOpen(), newOrgLabor.getWedOpen()); Assert.assertEquals(existingOrgLabor.getWedClose(), newOrgLabor.getWedClose()); Assert.assertEquals(existingOrgLabor.getThuOpen(), newOrgLabor.getThuOpen()); Assert.assertEquals(existingOrgLabor.getThuClose(), newOrgLabor.getThuClose()); Assert.assertEquals(existingOrgLabor.getFriOpen(), newOrgLabor.getFriOpen()); Assert.assertEquals(existingOrgLabor.getFriClose(), newOrgLabor.getFriClose()); Assert.assertEquals(existingOrgLabor.getSatOpen(), newOrgLabor.getSatOpen()); Assert.assertEquals(existingOrgLabor.getSatClose(), newOrgLabor.getSatClose()); }