コード例 #1
0
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    Team newTeam = addTeam();

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

    primaryKeys.add(newTeam.getPrimaryKey());

    Map<Serializable, Team> teams = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, teams.size());
    Assert.assertEquals(newTeam, teams.get(newTeam.getPrimaryKey()));
  }
コード例 #2
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    Team newTeam = addTeam();

    long pk = RandomTestUtil.nextLong();

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

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

    Map<Serializable, Team> teams = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, teams.size());
    Assert.assertEquals(newTeam, teams.get(newTeam.getPrimaryKey()));
  }
コード例 #3
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    Team newTeam1 = addTeam();
    Team newTeam2 = addTeam();

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

    primaryKeys.add(newTeam1.getPrimaryKey());
    primaryKeys.add(newTeam2.getPrimaryKey());

    Map<Serializable, Team> teams = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, teams.size());
    Assert.assertEquals(newTeam1, teams.get(newTeam1.getPrimaryKey()));
    Assert.assertEquals(newTeam2, teams.get(newTeam2.getPrimaryKey()));
  }
コード例 #4
0
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    Team newTeam = addTeam();

    Team existingTeam = _persistence.fetchByPrimaryKey(newTeam.getPrimaryKey());

    Assert.assertEquals(existingTeam, newTeam);
  }
コード例 #5
0
  @Test
  public void testRemove() throws Exception {
    Team newTeam = addTeam();

    _persistence.remove(newTeam);

    Team existingTeam = _persistence.fetchByPrimaryKey(newTeam.getPrimaryKey());

    Assert.assertNull(existingTeam);
  }
コード例 #6
0
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Team team = _persistence.create(pk);

    Assert.assertNotNull(team);

    Assert.assertEquals(team.getPrimaryKey(), pk);
  }
コード例 #7
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Team newTeam = _persistence.create(pk);

    newTeam.setMvccVersion(RandomTestUtil.nextLong());

    newTeam.setUuid(RandomTestUtil.randomString());

    newTeam.setCompanyId(RandomTestUtil.nextLong());

    newTeam.setUserId(RandomTestUtil.nextLong());

    newTeam.setUserName(RandomTestUtil.randomString());

    newTeam.setCreateDate(RandomTestUtil.nextDate());

    newTeam.setModifiedDate(RandomTestUtil.nextDate());

    newTeam.setGroupId(RandomTestUtil.nextLong());

    newTeam.setName(RandomTestUtil.randomString());

    newTeam.setDescription(RandomTestUtil.randomString());

    newTeam.setLastPublishDate(RandomTestUtil.nextDate());

    _teams.add(_persistence.update(newTeam));

    Team existingTeam = _persistence.findByPrimaryKey(newTeam.getPrimaryKey());

    Assert.assertEquals(existingTeam.getMvccVersion(), newTeam.getMvccVersion());
    Assert.assertEquals(existingTeam.getUuid(), newTeam.getUuid());
    Assert.assertEquals(existingTeam.getTeamId(), newTeam.getTeamId());
    Assert.assertEquals(existingTeam.getCompanyId(), newTeam.getCompanyId());
    Assert.assertEquals(existingTeam.getUserId(), newTeam.getUserId());
    Assert.assertEquals(existingTeam.getUserName(), newTeam.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingTeam.getCreateDate()),
        Time.getShortTimestamp(newTeam.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingTeam.getModifiedDate()),
        Time.getShortTimestamp(newTeam.getModifiedDate()));
    Assert.assertEquals(existingTeam.getGroupId(), newTeam.getGroupId());
    Assert.assertEquals(existingTeam.getName(), newTeam.getName());
    Assert.assertEquals(existingTeam.getDescription(), newTeam.getDescription());
    Assert.assertEquals(
        Time.getShortTimestamp(existingTeam.getLastPublishDate()),
        Time.getShortTimestamp(newTeam.getLastPublishDate()));
  }
コード例 #8
0
  @Test
  public void testResetOriginalValues() throws Exception {
    Team newTeam = addTeam();

    _persistence.clearCache();

    Team existingTeam = _persistence.findByPrimaryKey(newTeam.getPrimaryKey());

    Assert.assertTrue(
        Objects.equals(
            existingTeam.getUuid(),
            ReflectionTestUtil.invoke(existingTeam, "getOriginalUuid", new Class<?>[0])));
    Assert.assertEquals(
        Long.valueOf(existingTeam.getGroupId()),
        ReflectionTestUtil.<Long>invoke(existingTeam, "getOriginalGroupId", new Class<?>[0]));

    Assert.assertEquals(
        Long.valueOf(existingTeam.getGroupId()),
        ReflectionTestUtil.<Long>invoke(existingTeam, "getOriginalGroupId", new Class<?>[0]));
    Assert.assertTrue(
        Objects.equals(
            existingTeam.getName(),
            ReflectionTestUtil.invoke(existingTeam, "getOriginalName", new Class<?>[0])));
  }