Examples of JpaPerson


Examples of org.apache.rave.portal.model.JpaPerson

    }

    @Test
    public void testNoConversion() {
        JpaPerson template = new JpaPerson();
        assertThat(converter.convert(template), is(sameInstance(template)));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

        template.setStatus("TEST_K");
        template.setAddresses(new ArrayList<Address>());
        template.setOrganizations(new ArrayList<Organization>());
        template.setProperties(new ArrayList<PersonProperty>());

        JpaPerson jpaTemplate = converter.convert(template);

        assertThat(jpaTemplate, is(not(sameInstance(template))));
        assertThat(jpaTemplate, is(instanceOf(JpaPerson.class)));
        assertThat(jpaTemplate.getUsername(), is(equalTo(template.getUsername())));
        assertThat(jpaTemplate.getEmail(), is(equalTo(template.getEmail())));
        assertThat(jpaTemplate.getDisplayName(), is(equalTo(template.getDisplayName())));
        assertThat(jpaTemplate.getUsername(), is(equalTo(template.getUsername())));
        assertThat(jpaTemplate.getFamilyName(), is(equalTo(template.getFamilyName())));
        assertThat(jpaTemplate.getGivenName(), is(equalTo(template.getGivenName())));
        assertThat(jpaTemplate.getHonorificPrefix(), is(equalTo(template.getHonorificPrefix())));
        assertThat(jpaTemplate.getHonorificSuffix(), is(equalTo(template.getHonorificSuffix())));
        assertThat(jpaTemplate.getPreferredName(), is(equalTo(template.getPreferredName())));
        assertThat(jpaTemplate.getAboutMe(), is(equalTo(template.getAboutMe())));
        assertThat(jpaTemplate.getStatus(), is(equalTo(template.getStatus())));
        assertThat(jpaTemplate.getAddresses(), is(equalTo(template.getAddresses())));
        assertThat(jpaTemplate.getOrganizations(), is(equalTo(template.getOrganizations())));
        assertThat(jpaTemplate.getProperties(), is(equalTo(template.getProperties())));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

    @Before
    public void setup() throws NoSuchFieldException, IllegalAccessException {
        ModelConverter personConverter = createMock(ModelConverter.class);
        expect(personConverter.getSourceType()).andReturn(Person.class).anyTimes();
        expect(personConverter.convert(isA(PersonImpl.class))).andReturn(new JpaPerson());
        replay(personConverter);

        ModelConverter addressConverter = createMock(ModelConverter.class);
        expect(addressConverter.getSourceType()).andReturn(Address.class).anyTimes();
        expect(addressConverter.convert(isA(AddressImpl.class))).andReturn(new JpaAddress());
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

    public Class<Person> getSourceType() {
        return Person.class;
    }

    private JpaPerson createEntity(Person source) {
        JpaPerson converted = null;
        if (source != null) {
            TypedQuery<JpaPerson> query = manager.createNamedQuery(JpaPerson.FIND_BY_USERNAME, JpaPerson.class);
            query.setParameter(JpaPerson.USERNAME_PARAM, source.getUsername());
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaPerson();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

        assertEquals(repository.getType(), JpaPerson.class);
    }

    @Test
    public void get() {
        JpaPerson p = (JpaPerson) repository.get(VALID_ID);
        assertThat(p.getEntityId().toString(), is(VALID_ID));
        assertThat(p.getUsername(), is(VALID_USER));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_new() {
        final String NEW_USERNAME = "test123";
        final String NEW_ABOUT_ME = "about me blah blah";
        JpaPerson person = new JpaPerson();
        person.setUsername(NEW_USERNAME);
        person.setAboutMe(NEW_ABOUT_ME);

        assertThat(person.getEntityId(), is(nullValue()));
        repository.save(person);
        Long newId = person.getEntityId();
        assertThat(newId > 0, is(true));
        JpaPerson newPerson = (JpaPerson) repository.get(newId.toString());
        assertThat(newPerson.getAboutMe(), is(NEW_ABOUT_ME));
        assertThat(newPerson.getUsername(), is(NEW_USERNAME));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

    public Class<Person> getSourceType() {
        return Person.class;
    }

    private JpaPerson createEntity(Person source) {
        JpaPerson converted = null;
        if (source != null) {
            TypedQuery<JpaPerson> query = manager.createNamedQuery(JpaPerson.FIND_BY_USERNAME, JpaPerson.class);
            query.setParameter(JpaPerson.USERNAME_PARAM, source.getUsername());
            converted = getSingleResult(query.getResultList());

            if (converted == null) {
                converted = new JpaPerson();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

        return manager.find(JpaPerson.class, id);
    }

    @Override
    public Person save(Person item) {
        JpaPerson person = personConverter.convert(item);
        return saveOrUpdate(person.getEntityId(), manager, person);
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

        assertEquals(repository.getType(), JpaPerson.class);
    }

    @Test
    public void get() {
        JpaPerson p = (JpaPerson) repository.get(VALID_ID);
        assertThat(p.getEntityId(), is(VALID_ID));
        assertThat(p.getUsername(), is(VALID_USER));
    }
View Full Code Here

Examples of org.apache.rave.portal.model.JpaPerson

    @Transactional(readOnly=false)
    @Rollback(true)
    public void save_new() {
        final String NEW_USERNAME = "test123";
        final String NEW_ABOUT_ME = "about me blah blah";
        JpaPerson person = new JpaPerson();
        person.setUsername(NEW_USERNAME);
        person.setAboutMe(NEW_ABOUT_ME);

        assertThat(person.getEntityId(), is(nullValue()));
        repository.save(person);
        long newId = person.getEntityId();
        assertThat(newId > 0, is(true));
        JpaPerson newPerson = (JpaPerson) repository.get(newId);
        assertThat(newPerson.getAboutMe(), is(NEW_ABOUT_ME));
        assertThat(newPerson.getUsername(), is(NEW_USERNAME));
    }
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.