Examples of UserContactType


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

     */
    private void fetchDataForValidation(Object value) {
        try {
            fieldValue = BeanUtils.getProperty(value, propertyToValidate);
            long typeId = Long.parseLong(BeanUtils.getProperty(value, pathToTypeId));
            UserContactType type = contactsService.get(typeId);
            pattern = type.getValidationPattern();
        } catch (Exception e) {
            throw new IllegalStateException(e);
        }
    }
View Full Code Here

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

 
  @BeforeMethod
  public void init() {
    //prepare help test values
    contactType = new UserContactType();
    contactType.setDisplayPattern(CONTACT_TEST_DISPLAY_PATTERN);
  }
View Full Code Here

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

                user.removeContact(contact);
            }
        }
        // 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);
View Full Code Here

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

    @BeforeMethod
    public void setUp() throws NotFoundException {
        initMocks(this);
        validator = new ValidUserContactValidator();
       
        UserContactType validContactType = new UserContactType();
        validContactType.setId(TYPE_ID_VALID);
        validContactType.setValidationPattern(VALID_PATTERN);
        UserContactType nullPatternContactType = new UserContactType();
        nullPatternContactType.setId(TYPE_ID_NULL_PATTERN);
        nullPatternContactType.setValidationPattern(null);
    when(contactsService.get(TYPE_ID_VALID)).thenReturn(validContactType);
    when(contactsService.get(TYPE_ID_NULL_PATTERN)).thenReturn(nullPatternContactType);
    when(contactsService.get(TYPE_ID_NON_EXISTENT)).thenThrow(new NotFoundException());
    validator = new ValidUserContactValidator();
    validator.setContactsService(contactsService);
View Full Code Here

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

        UserContactContainer contact1 = contacts.get(0);
        contact1.setTypeId(contactTypeId2);
        contact1.setValue(newValue2);

        prepareContactsMocks();
        UserContactType contactType = createUserContactType(contactTypeId2);
        when(userContactsDao.get(contactType.getId())).thenReturn(contactType);
        when(userContactsDao.isExist(anyLong())).thenReturn(true);

        JCUser resultUser = userContactsService.saveEditedUserContacts(user.getId(), contacts);
        assertEquals(resultUser.getContacts().size(), 1);
        List<UserContact> resultContacts = new ArrayList<>(resultUser.getContacts());
View Full Code Here

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

    public void saveEditedContactsShouldAddNewContacts() throws NotFoundException {
        long contactTypeId1 = 1;
        long typeIdForNewContact = 2;

        List<UserContactContainer> contacts = new ArrayList<>(addContactsToUser(user, 2, contactTypeId1));
        UserContactType typeForNewContact = createUserContactType(typeIdForNewContact);
        contacts.addAll(createNewContacts(3, typeIdForNewContact));

        prepareContactsMocks();
        when(userContactsDao.get(typeForNewContact.getId())).thenReturn(typeForNewContact);
        when(userContactsDao.isExist(anyLong())).thenReturn(true);

        JCUser resultUser = userContactsService.saveEditedUserContacts(user.getId(), contacts);
        assertEquals(resultUser.getContacts().size(), 5);
    }
View Full Code Here

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

        when(userService.get(user.getId())).thenReturn(user);
        List<UserContact> userContactList = Lists.newArrayList(user.getContacts());
        for (UserContact contact : userContactList) {
            if (contact.getId() != 0) {
                when(userContactsDao.getContactById(contact.getId())).thenReturn(contact);
                UserContactType contactType = contact.getType();
                when(userContactsDao.get(contactType.getId())).thenReturn(contactType);
            }
        }
    }
View Full Code Here

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

            }
        }
    }

    private static UserContactType createUserContactType(long contactTypeId) {
        UserContactType userContactType = new UserContactType();
        userContactType.setId(contactTypeId);
        userContactType.setTypeName(TYPENAME);
        userContactType.setIcon(ICON);
        return userContactType;
    }
View Full Code Here

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

        "The problem of copying data. Value - type.");
  }

    private UserContact prepareUserContact(){
        //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);
View Full Code Here

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

    }
   
    @Test
    public void testGetContactTypes() {
        List<UserContactType> expectedTypes = new ArrayList<UserContactType>();
        UserContactType expectedType = createUserContactType();
        expectedTypes.add(expectedType);
       
        when(service.getAvailableContactTypes()).thenReturn(expectedTypes);

        UserContactType[] types = controller.getContactTypes();
        assertEquals(types.length, expectedTypes.size());
        assertEquals(types[0].getIcon(), expectedType.getIcon());
        assertEquals(types[0].getTypeName(), expectedType.getTypeName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.