Package org.apache.rave.model

Examples of org.apache.rave.model.Person


    public void proxyAdd() {
        List<ModelConverter> converters = new ArrayList<ModelConverter>();
        ModelConverter converterMock = createMock(ModelConverter.class);
        expect(converterMock.getSourceType()).andReturn(Person.class).anyTimes();
        converters.add(converterMock);
        Person personImpl1 = new PersonImpl();
        PersonImpl personImpl2 = new PersonImpl();
        expect(converterMock.convert(personImpl1)).andReturn(personImpl2);
        replay(converterMock);
        List<PersonImpl> underlying = createMock(List.class);
        expect(underlying.add(personImpl2)).andReturn(true);
View Full Code Here


    public void proxySet() {
        List<ModelConverter> converters = new ArrayList<ModelConverter>();
        ModelConverter converterMock = createMock(ModelConverter.class);
        expect(converterMock.getSourceType()).andReturn(Person.class).anyTimes();
        converters.add(converterMock);
        Person personImpl1 = new PersonImpl();
        Person personImpl2 = new PersonImpl();
        expect(converterMock.convert(personImpl1)).andReturn(personImpl2);
        replay(converterMock);
        List<PersonImpl> underlying = createMock(List.class);
        expect(underlying.set(0, (PersonImpl)personImpl2)).andReturn((PersonImpl) personImpl2);
        replay(underlying);
        new JpaConverter(converters);

        List<Person> personProxy = ConvertingListProxyFactory.createProxyList(Person.class, underlying);
        Person good = personProxy.set(0, personImpl1);
        assertThat(good, is(sameInstance(personImpl2)));
        verify(converterMock);
        verify(underlying);
    }
View Full Code Here

    }

    @Test
    public void proxyAddAll() {

        Person personImpl1 = new PersonImpl();
        Person personImpl2 = new PersonImpl();
        Person personImpl3 = new PersonImpl();
        Person personImpl4 = new PersonImpl();

        List<ModelConverter> converters = new ArrayList<ModelConverter>();
        ModelConverter converterMock = createMock(ModelConverter.class);
        expect(converterMock.getSourceType()).andReturn(Person.class).anyTimes();
        converters.add(converterMock);
View Full Code Here

        assertThat(converter.convert(template), is(sameInstance(template)));
    }

    @Test
    public void nullConversion() {
        Person template = null;
        assertThat(converter.convert(template), is(nullValue()));
    }
View Full Code Here

    }


    @Test
    public void convertValid() {
        Person template = new PersonImpl();
        template.setUsername("TEST_A");
        template.setEmail("TEST_B");
        template.setDisplayName("TEST_C");
        template.setAdditionalName("TEST_D");
        template.setFamilyName("TEST_E");
        template.setGivenName("TEST_F");
        template.setHonorificPrefix("TEST_G");
        template.setHonorificSuffix("TEST_H");
        template.setPreferredName("TEST_I");
        template.setAboutMe("TEST_J");
        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

    @Override
    public SearchResult<Person> getLimitedListOfPersons(int offset, int pageSize) {
        SearchResult<User> users = getLimitedListOfUsers(offset, pageSize);
        int count = users.getTotalResults();
        List<Person> people = new ArrayList<Person>();
        Person person = null;
        for(User user : users.getResultSet()){
            person = user.toPerson();
            person.setId(user.getId());
            people.add(person);
        }
        return new SearchResult<Person>(people, count);
    }
View Full Code Here

    @Override
    public SearchResult<Person> getPersonsByFreeTextSearch(String searchTerm, int offset, int pageSize) {
        SearchResult<User> users = getUsersByFreeTextSearch(searchTerm, offset, pageSize);
        int count = users.getTotalResults();
        List<Person> people = new ArrayList<Person>();
        Person person = null;
        for(User user : users.getResultSet()){
            person = user.toPerson();
            person.setId(user.getId());
            people.add(person);
        }
        return new SearchResult<Person>(people, count);
    }
View Full Code Here

        tag.setPageContext(pageContext);
    }

    @Test
    public void doStartTag_allSet() throws IOException, JspException {
        Person p = new PersonImpl();

        expect(repository.get(VALID_ID)).andReturn(p);
        expect(pageContext.getServletContext()).andReturn(servletContext).anyTimes();
        expect(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(wContext).anyTimes();
        expect(wContext.getBean(PersonRepository.class)).andReturn(repository).anyTimes();
View Full Code Here

        verify(repository, pageContext, servletContext, wContext, writer);
    }

    @Test
    public void doStartTag_varSet() throws IOException, JspException {
        Person p = new PersonImpl();

        expect(repository.get(VALID_ID)).andReturn(p);
        expect(pageContext.getServletContext()).andReturn(servletContext).anyTimes();
        expect(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(wContext).anyTimes();
        expect(wContext.getBean(PersonRepository.class)).andReturn(repository).anyTimes();
View Full Code Here

        verify(repository, pageContext, servletContext, wContext, writer);
    }

    @Test
    public void doStartTag_novar() throws IOException, JspException {
        Person p = new PersonImpl();
        p.setUsername("FOO");

        expect(repository.get(VALID_ID)).andReturn(p);
        expect(pageContext.getServletContext()).andReturn(servletContext).anyTimes();
        expect(servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE)).andReturn(wContext).anyTimes();
        expect(wContext.getBean(PersonRepository.class)).andReturn(repository).anyTimes();
        expect(pageContext.getOut()).andReturn(writer).anyTimes();
        writer.print(p.getUsername());
        expectLastCall();
        replay(repository, pageContext, servletContext, wContext, writer);

        tag.setId(VALID_ID);
        int result = tag.doEndTag();
View Full Code Here

TOP

Related Classes of org.apache.rave.model.Person

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.