Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.UserContact


        assertReflectionEquals(type, types.get(0));
    }

    @Test
    public void testGetContactById() {
        UserContact contact = ObjectsFactory.getDefaultUserContact();
        session.saveOrUpdate(contact.getOwner());
        session.saveOrUpdate(contact.getType());
        session.saveOrUpdate(contact);

        UserContact persisted = dao.getContactById(contact.getId());

        assertEquals(contact, persisted);
    }
View Full Code Here


            }
        }
        // Add new and edit existing contacts
        for (UserContactContainer contactContainer: contacts) {
            UserContactType actualType = get(contactContainer.getTypeId());
            UserContact contact = contactContainer.getId() == null ? null
                    : this.getDao().getContactById(contactContainer.getId());
            if (contact != null && contact.getOwner().getId() == user.getId()) {
                contact.setValue(contactContainer.getValue());
                contact.setType(actualType);
            } else {
                contact = new UserContact(contactContainer.getValue(), actualType);
                user.addContact(contact);
            }
        }
        return user;
    }
View Full Code Here

     * @return added contacts as contact containers
     */
    private static List<UserContactContainer> addContactsToUser(JCUser user, long contactsCount, long contactTypeId) {
        List<UserContactContainer> contacts = new ArrayList<>();
        for (int i = 0; i < contactsCount; i++) {
            UserContact contact = new UserContact("contact" + i, createUserContactType(contactTypeId));
            contact.setId(user.getContacts().size() + 1);
            user.addContact(contact);
            contacts.add(new UserContactContainer(contact.getId(), contact.getValue(), contact.getType().getId()));
        }
        return contacts;
    }
View Full Code Here

*/
public class UserContactDtoTest {

  @Test
  public void testCreateFromUserContact() {
      UserContact userContact = prepareUserContact();
    //create
    UserContactDto contactDto = new UserContactDto(userContact);
    //check content
    assertEquals(contactDto.getValue(), userContact.getValue(),
        "The problem of copying data. Value - value.");
    assertEquals(contactDto.getId(), Long.valueOf(userContact.getId()),
        "The problem of copying data. Value - Id.");
    assertEquals(contactDto.getType().getId(), userContact.getType().getId(),
        "The problem of copying data. Value - type.");
  }
View Full Code Here

        //prepare help test values
        UserContactType contactType = new UserContactType();
        JCUser user = new JCUser("username", "email", "password");
        user.setId(1);
        //init main test value
        UserContact userContact = new UserContact("10-10-10", contactType);
        userContact.setOwner(user);
        return userContact;
    }
View Full Code Here

    }

    private UserContact createUserContact(long ownerId, UserContactType contactType){
        JCUser owner = new JCUser("username", "email", "password");
        owner.setId(ownerId);
        UserContact contact = new UserContact("gateway", contactType);
        contact.setOwner(owner);
        return contact;
    }
View Full Code Here

        assertEquals(contact, persisted);
    }

    @Test
    public void testGetContactByWrongId() {
        UserContact persisted = dao.getContactById(5L);

        assertNull(persisted);
    }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.UserContact

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.