コード例 #1
0
  @Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    Contact newContact = addContact();

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

    primaryKeys.add(newContact.getPrimaryKey());

    Map<Serializable, Contact> contacts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, contacts.size());
    Assert.assertEquals(newContact, contacts.get(newContact.getPrimaryKey()));
  }
コード例 #2
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    Contact newContact = addContact();

    long pk = RandomTestUtil.nextLong();

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

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

    Map<Serializable, Contact> contacts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, contacts.size());
    Assert.assertEquals(newContact, contacts.get(newContact.getPrimaryKey()));
  }
コード例 #3
0
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    Contact newContact1 = addContact();
    Contact newContact2 = addContact();

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

    primaryKeys.add(newContact1.getPrimaryKey());
    primaryKeys.add(newContact2.getPrimaryKey());

    Map<Serializable, Contact> contacts = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, contacts.size());
    Assert.assertEquals(newContact1, contacts.get(newContact1.getPrimaryKey()));
    Assert.assertEquals(newContact2, contacts.get(newContact2.getPrimaryKey()));
  }
コード例 #4
0
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    Contact newContact = addContact();

    Contact existingContact = _persistence.fetchByPrimaryKey(newContact.getPrimaryKey());

    Assert.assertEquals(existingContact, newContact);
  }
コード例 #5
0
  @Test
  public void testRemove() throws Exception {
    Contact newContact = addContact();

    _persistence.remove(newContact);

    Contact existingContact = _persistence.fetchByPrimaryKey(newContact.getPrimaryKey());

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

    Contact contact = _persistence.create(pk);

    Assert.assertNotNull(contact);

    Assert.assertEquals(contact.getPrimaryKey(), pk);
  }
コード例 #7
0
  public int compareTo(Contact contact) {
    long primaryKey = contact.getPrimaryKey();

    if (getPrimaryKey() < primaryKey) {
      return -1;
    } else if (getPrimaryKey() > primaryKey) {
      return 1;
    } else {
      return 0;
    }
  }
コード例 #8
0
  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    Contact contact = null;

    try {
      contact = (Contact) obj;
    } catch (ClassCastException cce) {
      return false;
    }

    long primaryKey = contact.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
コード例 #9
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Contact newContact = _persistence.create(pk);

    newContact.setMvccVersion(RandomTestUtil.nextLong());

    newContact.setCompanyId(RandomTestUtil.nextLong());

    newContact.setUserId(RandomTestUtil.nextLong());

    newContact.setUserName(RandomTestUtil.randomString());

    newContact.setCreateDate(RandomTestUtil.nextDate());

    newContact.setModifiedDate(RandomTestUtil.nextDate());

    newContact.setClassNameId(RandomTestUtil.nextLong());

    newContact.setClassPK(RandomTestUtil.nextLong());

    newContact.setAccountId(RandomTestUtil.nextLong());

    newContact.setParentContactId(RandomTestUtil.nextLong());

    newContact.setEmailAddress(RandomTestUtil.randomString());

    newContact.setFirstName(RandomTestUtil.randomString());

    newContact.setMiddleName(RandomTestUtil.randomString());

    newContact.setLastName(RandomTestUtil.randomString());

    newContact.setPrefixId(RandomTestUtil.nextLong());

    newContact.setSuffixId(RandomTestUtil.nextLong());

    newContact.setMale(RandomTestUtil.randomBoolean());

    newContact.setBirthday(RandomTestUtil.nextDate());

    newContact.setSmsSn(RandomTestUtil.randomString());

    newContact.setFacebookSn(RandomTestUtil.randomString());

    newContact.setJabberSn(RandomTestUtil.randomString());

    newContact.setSkypeSn(RandomTestUtil.randomString());

    newContact.setTwitterSn(RandomTestUtil.randomString());

    newContact.setEmployeeStatusId(RandomTestUtil.randomString());

    newContact.setEmployeeNumber(RandomTestUtil.randomString());

    newContact.setJobTitle(RandomTestUtil.randomString());

    newContact.setJobClass(RandomTestUtil.randomString());

    newContact.setHoursOfOperation(RandomTestUtil.randomString());

    _contacts.add(_persistence.update(newContact));

    Contact existingContact = _persistence.findByPrimaryKey(newContact.getPrimaryKey());

    Assert.assertEquals(existingContact.getMvccVersion(), newContact.getMvccVersion());
    Assert.assertEquals(existingContact.getContactId(), newContact.getContactId());
    Assert.assertEquals(existingContact.getCompanyId(), newContact.getCompanyId());
    Assert.assertEquals(existingContact.getUserId(), newContact.getUserId());
    Assert.assertEquals(existingContact.getUserName(), newContact.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getCreateDate()),
        Time.getShortTimestamp(newContact.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getModifiedDate()),
        Time.getShortTimestamp(newContact.getModifiedDate()));
    Assert.assertEquals(existingContact.getClassNameId(), newContact.getClassNameId());
    Assert.assertEquals(existingContact.getClassPK(), newContact.getClassPK());
    Assert.assertEquals(existingContact.getAccountId(), newContact.getAccountId());
    Assert.assertEquals(existingContact.getParentContactId(), newContact.getParentContactId());
    Assert.assertEquals(existingContact.getEmailAddress(), newContact.getEmailAddress());
    Assert.assertEquals(existingContact.getFirstName(), newContact.getFirstName());
    Assert.assertEquals(existingContact.getMiddleName(), newContact.getMiddleName());
    Assert.assertEquals(existingContact.getLastName(), newContact.getLastName());
    Assert.assertEquals(existingContact.getPrefixId(), newContact.getPrefixId());
    Assert.assertEquals(existingContact.getSuffixId(), newContact.getSuffixId());
    Assert.assertEquals(existingContact.getMale(), newContact.getMale());
    Assert.assertEquals(
        Time.getShortTimestamp(existingContact.getBirthday()),
        Time.getShortTimestamp(newContact.getBirthday()));
    Assert.assertEquals(existingContact.getSmsSn(), newContact.getSmsSn());
    Assert.assertEquals(existingContact.getFacebookSn(), newContact.getFacebookSn());
    Assert.assertEquals(existingContact.getJabberSn(), newContact.getJabberSn());
    Assert.assertEquals(existingContact.getSkypeSn(), newContact.getSkypeSn());
    Assert.assertEquals(existingContact.getTwitterSn(), newContact.getTwitterSn());
    Assert.assertEquals(existingContact.getEmployeeStatusId(), newContact.getEmployeeStatusId());
    Assert.assertEquals(existingContact.getEmployeeNumber(), newContact.getEmployeeNumber());
    Assert.assertEquals(existingContact.getJobTitle(), newContact.getJobTitle());
    Assert.assertEquals(existingContact.getJobClass(), newContact.getJobClass());
    Assert.assertEquals(existingContact.getHoursOfOperation(), newContact.getHoursOfOperation());
  }