コード例 #1
0
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    MBBan newMBBan = addMBBan();

    MBBan existingMBBan = _persistence.fetchByPrimaryKey(newMBBan.getPrimaryKey());

    Assert.assertEquals(existingMBBan, newMBBan);
  }
コード例 #2
0
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan mbBan = _persistence.create(pk);

    Assert.assertNotNull(mbBan);

    Assert.assertEquals(mbBan.getPrimaryKey(), pk);
  }
コード例 #3
0
  @Test
  public void testRemove() throws Exception {
    MBBan newMBBan = addMBBan();

    _persistence.remove(newMBBan);

    MBBan existingMBBan = _persistence.fetchByPrimaryKey(newMBBan.getPrimaryKey());

    Assert.assertNull(existingMBBan);
  }
コード例 #4
0
  protected MBBan addMBBan() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan mbBan = _persistence.create(pk);

    mbBan.setUuid(RandomTestUtil.randomString());

    mbBan.setGroupId(RandomTestUtil.nextLong());

    mbBan.setCompanyId(RandomTestUtil.nextLong());

    mbBan.setUserId(RandomTestUtil.nextLong());

    mbBan.setUserName(RandomTestUtil.randomString());

    mbBan.setCreateDate(RandomTestUtil.nextDate());

    mbBan.setModifiedDate(RandomTestUtil.nextDate());

    mbBan.setBanUserId(RandomTestUtil.nextLong());

    _mbBans.add(_persistence.update(mbBan));

    return mbBan;
  }
コード例 #5
0
  @Override
  protected void validateImport(
      StagedModel stagedModel, Map<String, List<StagedModel>> dependentStagedModelsMap, Group group)
      throws Exception {

    super.validateImport(stagedModel, dependentStagedModelsMap, group);

    MBBan ban = (MBBan) stagedModel;
    MBBan importBan = (MBBan) getStagedModel(stagedModel.getUuid(), group);

    Assert.assertEquals(ban.getBanUserUuid(), importBan.getBanUserUuid());
  }
コード例 #6
0
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    MBBan newMBBan = addMBBan();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBBan.getPrimaryKey());

    Map<Serializable, MBBan> mbBans = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mbBans.size());
    Assert.assertEquals(newMBBan, mbBans.get(newMBBan.getPrimaryKey()));
  }
コード例 #7
0
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    MBBan newMBBan = addMBBan();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBBan.class, MBBan.class.getClassLoader());

    dynamicQuery.add(RestrictionsFactoryUtil.eq("banId", newMBBan.getBanId()));

    List<MBBan> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    MBBan existingMBBan = result.get(0);

    Assert.assertEquals(existingMBBan, newMBBan);
  }
コード例 #8
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    MBBan newMBBan = addMBBan();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBBan.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, MBBan> mbBans = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, mbBans.size());
    Assert.assertEquals(newMBBan, mbBans.get(newMBBan.getPrimaryKey()));
  }
コード例 #9
0
  /**
   * 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 MBBan toModel(MBBanSoap soapModel) {
    MBBan model = new MBBanImpl();

    model.setBanId(soapModel.getBanId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setBanUserId(soapModel.getBanUserId());

    return model;
  }
コード例 #10
0
ファイル: MBUtil.java プロジェクト: JamesLefeu/liferay-portal
  public static Date getUnbanDate(MBBan ban, int expireInterval) {
    Date banDate = ban.getCreateDate();

    Calendar cal = Calendar.getInstance();

    cal.setTime(banDate);

    cal.add(Calendar.DATE, expireInterval);

    return cal.getTime();
  }
コード例 #11
0
  public int compareTo(MBBan mbBan) {
    long pk = mbBan.getPrimaryKey();

    if (getPrimaryKey() < pk) {
      return -1;
    } else if (getPrimaryKey() > pk) {
      return 1;
    } else {
      return 0;
    }
  }
コード例 #12
0
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    MBBan newMBBan = addMBBan();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(MBBan.class, MBBan.class.getClassLoader());

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("banId"));

    Object newBanId = newMBBan.getBanId();

    dynamicQuery.add(RestrictionsFactoryUtil.in("banId", new Object[] {newBanId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingBanId = result.get(0);

    Assert.assertEquals(existingBanId, newBanId);
  }
コード例 #13
0
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    MBBan mbBan = null;

    try {
      mbBan = (MBBan) obj;
    } catch (ClassCastException cce) {
      return false;
    }

    long pk = mbBan.getPrimaryKey();

    if (getPrimaryKey() == pk) {
      return true;
    } else {
      return false;
    }
  }
コード例 #14
0
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    MBBan newMBBan = addMBBan();

    _persistence.clearCache();

    MBBanModelImpl existingMBBanModelImpl =
        (MBBanModelImpl) _persistence.findByPrimaryKey(newMBBan.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingMBBanModelImpl.getUuid(), existingMBBanModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingMBBanModelImpl.getGroupId(), existingMBBanModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingMBBanModelImpl.getGroupId(), existingMBBanModelImpl.getOriginalGroupId());
    Assert.assertEquals(
        existingMBBanModelImpl.getBanUserId(), existingMBBanModelImpl.getOriginalBanUserId());
  }
コード例 #15
0
  /**
   * Adds the message boards ban to the database. Also notifies the appropriate model listeners.
   *
   * @param mbBan the message boards ban
   * @return the message boards ban that was added
   * @throws SystemException if a system exception occurred
   */
  public MBBan addMBBan(MBBan mbBan) throws SystemException {
    mbBan.setNew(true);

    mbBan = mbBanPersistence.update(mbBan, false);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.reindex(mbBan);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }

    return mbBan;
  }
コード例 #16
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    MBBan newMBBan1 = addMBBan();
    MBBan newMBBan2 = addMBBan();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newMBBan1.getPrimaryKey());
    primaryKeys.add(newMBBan2.getPrimaryKey());

    Map<Serializable, MBBan> mbBans = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, mbBans.size());
    Assert.assertEquals(newMBBan1, mbBans.get(newMBBan1.getPrimaryKey()));
    Assert.assertEquals(newMBBan2, mbBans.get(newMBBan2.getPrimaryKey()));
  }
コード例 #17
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    MBBan newMBBan = _persistence.create(pk);

    newMBBan.setUuid(RandomTestUtil.randomString());

    newMBBan.setGroupId(RandomTestUtil.nextLong());

    newMBBan.setCompanyId(RandomTestUtil.nextLong());

    newMBBan.setUserId(RandomTestUtil.nextLong());

    newMBBan.setUserName(RandomTestUtil.randomString());

    newMBBan.setCreateDate(RandomTestUtil.nextDate());

    newMBBan.setModifiedDate(RandomTestUtil.nextDate());

    newMBBan.setBanUserId(RandomTestUtil.nextLong());

    _mbBans.add(_persistence.update(newMBBan));

    MBBan existingMBBan = _persistence.findByPrimaryKey(newMBBan.getPrimaryKey());

    Assert.assertEquals(existingMBBan.getUuid(), newMBBan.getUuid());
    Assert.assertEquals(existingMBBan.getBanId(), newMBBan.getBanId());
    Assert.assertEquals(existingMBBan.getGroupId(), newMBBan.getGroupId());
    Assert.assertEquals(existingMBBan.getCompanyId(), newMBBan.getCompanyId());
    Assert.assertEquals(existingMBBan.getUserId(), newMBBan.getUserId());
    Assert.assertEquals(existingMBBan.getUserName(), newMBBan.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBBan.getCreateDate()),
        Time.getShortTimestamp(newMBBan.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingMBBan.getModifiedDate()),
        Time.getShortTimestamp(newMBBan.getModifiedDate()));
    Assert.assertEquals(existingMBBan.getBanUserId(), newMBBan.getBanUserId());
  }
コード例 #18
0
  /**
   * Updates the message boards ban in the database. Also notifies the appropriate model listeners.
   *
   * @param mbBan the message boards ban to update
   * @param merge whether to merge the message boards ban with the current session. See {@link
   *     com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session,
   *     com.liferay.portal.model.BaseModel, boolean)} for an explanation.
   * @return the message boards ban that was updated
   * @throws SystemException if a system exception occurred
   */
  public MBBan updateMBBan(MBBan mbBan, boolean merge) throws SystemException {
    mbBan.setNew(false);

    return mbBanPersistence.update(mbBan, merge);
  }
コード例 #19
0
  /**
   * Adds the message boards ban to the database. Also notifies the appropriate model listeners.
   *
   * @param mbBan the message boards ban to add
   * @return the message boards ban that was added
   * @throws SystemException if a system exception occurred
   */
  public MBBan addMBBan(MBBan mbBan) throws SystemException {
    mbBan.setNew(true);

    return mbBanPersistence.update(mbBan, false);
  }