Package org.apache.rave.portal.model

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


        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

    @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

    @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

        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

    @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

    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

        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

    @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

TOP

Related Classes of org.apache.rave.portal.model.JpaPerson

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.