@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting(); _persistence.clearCache(); SocialActivitySettingModelImpl existingSocialActivitySettingModelImpl = (SocialActivitySettingModelImpl) _persistence.findByPrimaryKey(newSocialActivitySetting.getPrimaryKey()); Assert.assertEquals( existingSocialActivitySettingModelImpl.getGroupId(), existingSocialActivitySettingModelImpl.getOriginalGroupId()); Assert.assertEquals( existingSocialActivitySettingModelImpl.getClassNameId(), existingSocialActivitySettingModelImpl.getOriginalClassNameId()); Assert.assertEquals( existingSocialActivitySettingModelImpl.getActivityType(), existingSocialActivitySettingModelImpl.getOriginalActivityType()); Assert.assertTrue( Validator.equals( existingSocialActivitySettingModelImpl.getName(), existingSocialActivitySettingModelImpl.getOriginalName())); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting(); SocialActivitySetting existingSocialActivitySetting = _persistence.fetchByPrimaryKey(newSocialActivitySetting.getPrimaryKey()); Assert.assertEquals(existingSocialActivitySetting, newSocialActivitySetting); }
@Test public void testCreate() throws Exception { long pk = RandomTestUtil.nextLong(); SocialActivitySetting socialActivitySetting = _persistence.create(pk); Assert.assertNotNull(socialActivitySetting); Assert.assertEquals(socialActivitySetting.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting(); _persistence.remove(newSocialActivitySetting); SocialActivitySetting existingSocialActivitySetting = _persistence.fetchByPrimaryKey(newSocialActivitySetting.getPrimaryKey()); Assert.assertNull(existingSocialActivitySetting); }
protected Map<String, Boolean> getActivitySettingsMap(ThemeDisplay themeDisplay) throws Exception { Map<String, Boolean> activitySettingsMap = new LinkedHashMap<>(); List<SocialActivitySetting> activitySettings = SocialActivitySettingServiceUtil.getActivitySettings( themeDisplay.getSiteGroupIdOrLiveGroupId()); String[] modelNames = SocialConfigurationUtil.getActivityModelNames(); Comparator<String> comparator = new ModelResourceComparator(themeDisplay.getLocale()); Arrays.sort(modelNames, comparator); for (String modelName : modelNames) { List<SocialActivityDefinition> activityDefinitions = SocialActivitySettingServiceUtil.getActivityDefinitions( themeDisplay.getScopeGroupId(), modelName); for (SocialActivityDefinition activityDefinition : activityDefinitions) { if (activityDefinition.isCountersEnabled()) { activitySettingsMap.put(modelName, false); break; } } } for (SocialActivitySetting activitySetting : activitySettings) { String name = activitySetting.getName(); if (name.equals("enabled") && activitySettingsMap.containsKey(activitySetting.getClassName())) { activitySettingsMap.put( activitySetting.getClassName(), GetterUtil.getBoolean(activitySetting.getValue())); } } return activitySettingsMap; }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( SocialActivitySetting.class, SocialActivitySetting.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq( "activitySettingId", newSocialActivitySetting.getActivitySettingId())); List<SocialActivitySetting> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); SocialActivitySetting existingSocialActivitySetting = result.get(0); Assert.assertEquals(existingSocialActivitySetting, newSocialActivitySetting); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof SocialActivitySetting)) { return false; } SocialActivitySetting socialActivitySetting = (SocialActivitySetting) obj; long primaryKey = socialActivitySetting.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
@Override public int compareTo(SocialActivitySetting socialActivitySetting) { long primaryKey = socialActivitySetting.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { SocialActivitySetting newSocialActivitySetting = addSocialActivitySetting(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( SocialActivitySetting.class, SocialActivitySetting.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("activitySettingId")); Object newActivitySettingId = newSocialActivitySetting.getActivitySettingId(); dynamicQuery.add( RestrictionsFactoryUtil.in("activitySettingId", new Object[] {newActivitySettingId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingActivitySettingId = result.get(0); Assert.assertEquals(existingActivitySettingId, newActivitySettingId); }
/** * Converts the soap model instance into a normal model instance. * * @param soapModel the soap model instance to convert * @return the normal model instance */ public static SocialActivitySetting toModel(SocialActivitySettingSoap soapModel) { if (soapModel == null) { return null; } SocialActivitySetting model = new SocialActivitySettingImpl(); model.setActivitySettingId(soapModel.getActivitySettingId()); model.setGroupId(soapModel.getGroupId()); model.setCompanyId(soapModel.getCompanyId()); model.setClassNameId(soapModel.getClassNameId()); model.setActivityType(soapModel.getActivityType()); model.setName(soapModel.getName()); model.setValue(soapModel.getValue()); return model; }
protected SocialActivitySetting addSocialActivitySetting() throws Exception { long pk = RandomTestUtil.nextLong(); SocialActivitySetting socialActivitySetting = _persistence.create(pk); socialActivitySetting.setGroupId(RandomTestUtil.nextLong()); socialActivitySetting.setCompanyId(RandomTestUtil.nextLong()); socialActivitySetting.setClassNameId(RandomTestUtil.nextLong()); socialActivitySetting.setActivityType(RandomTestUtil.nextInt()); socialActivitySetting.setName(RandomTestUtil.randomString()); socialActivitySetting.setValue(RandomTestUtil.randomString()); _persistence.update(socialActivitySetting); return socialActivitySetting; }
@Override public Long get(SocialActivitySetting socialActivitySetting) { return socialActivitySetting.getActivitySettingId(); }
@Test public void testUpdateExisting() throws Exception { long pk = RandomTestUtil.nextLong(); SocialActivitySetting newSocialActivitySetting = _persistence.create(pk); newSocialActivitySetting.setGroupId(RandomTestUtil.nextLong()); newSocialActivitySetting.setCompanyId(RandomTestUtil.nextLong()); newSocialActivitySetting.setClassNameId(RandomTestUtil.nextLong()); newSocialActivitySetting.setActivityType(RandomTestUtil.nextInt()); newSocialActivitySetting.setName(RandomTestUtil.randomString()); newSocialActivitySetting.setValue(RandomTestUtil.randomString()); _persistence.update(newSocialActivitySetting); SocialActivitySetting existingSocialActivitySetting = _persistence.findByPrimaryKey(newSocialActivitySetting.getPrimaryKey()); Assert.assertEquals( existingSocialActivitySetting.getActivitySettingId(), newSocialActivitySetting.getActivitySettingId()); Assert.assertEquals( existingSocialActivitySetting.getGroupId(), newSocialActivitySetting.getGroupId()); Assert.assertEquals( existingSocialActivitySetting.getCompanyId(), newSocialActivitySetting.getCompanyId()); Assert.assertEquals( existingSocialActivitySetting.getClassNameId(), newSocialActivitySetting.getClassNameId()); Assert.assertEquals( existingSocialActivitySetting.getActivityType(), newSocialActivitySetting.getActivityType()); Assert.assertEquals( existingSocialActivitySetting.getName(), newSocialActivitySetting.getName()); Assert.assertEquals( existingSocialActivitySetting.getValue(), newSocialActivitySetting.getValue()); }