Package org.apache.rave.portal.model

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


    @Autowired
    private JpaAddressConverter addressConverter;

    @Test
    public void noConversion() {
        Address address = new JpaAddress();
        assertThat(addressConverter.convert(address), is(sameInstance(address)));
    }
View Full Code Here


        address.setLocality("Washington DC");
        address.setCountry("USA");
        address.setRegion("Washington DC");
        address.setPrimary(true);

        JpaAddress converted = addressConverter.convert(address);
        assertThat(converted, is(not(sameInstance(address))));
        assertThat(converted, is(instanceOf(JpaAddress.class)));
        assertThat(converted.getStreetAddress(), is(equalTo(address.getStreetAddress())));
        assertThat(converted.getLocality(), is(equalTo(address.getLocality())));
        assertThat(converted.getCountry(), is(equalTo(address.getCountry())));
        assertThat(converted.getRegion(), is(equalTo(address.getRegion())));
        assertThat(converted.getPrimary(), is(true));
    }
View Full Code Here

        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());
        replay(addressConverter);

        ModelConverter pageLayoutConverter = createMock(ModelConverter.class);
        expect(pageLayoutConverter.getSourceType()).andReturn(Address.class).anyTimes();
        expect(pageLayoutConverter.convert(isA(PageLayout.class))).andReturn(new JpaPageLayout());
View Full Code Here

    public JpaAddress convert(Address source) {
        return source instanceof JpaAddress ? (JpaAddress) source : createEntity(source);
    }

    private JpaAddress createEntity(Address source) {
        JpaAddress converted = null;
        if (source != null) {
            TypedQuery<JpaAddress> query = manager.createNamedQuery(JpaAddress.FIND_BY_STREET_CITY_COUNTRY, JpaAddress.class);
            query.setParameter(JpaAddress.STREET_PARAM, source.getStreetAddress());
            query.setParameter(JpaAddress.CITY_PARAM, source.getLocality());
            query.setParameter(JpaAddress.COUNTRY_PARAM, source.getCountry());
            converted = getSingleResult(query.getResultList());

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

        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());
        replay(addressConverter);

        ModelConverter pageLayoutConverter = createMock(ModelConverter.class);
        expect(pageLayoutConverter.getSourceType()).andReturn(Address.class).anyTimes();
        expect(pageLayoutConverter.convert(isA(PageLayout.class))).andReturn(new JpaPageLayout());
View Full Code Here

    public JpaAddress convert(Address source) {
        return source instanceof JpaAddress ? (JpaAddress) source : createEntity(source);
    }

    private JpaAddress createEntity(Address source) {
        JpaAddress converted = null;
        if (source != null) {
            TypedQuery<JpaAddress> query = manager.createNamedQuery(JpaAddress.FIND_BY_STREET_CITY_COUNTRY, JpaAddress.class);
            query.setParameter(JpaAddress.STREET_PARAM, source.getStreetAddress());
            query.setParameter(JpaAddress.CITY_PARAM, source.getLocality());
            query.setParameter(JpaAddress.COUNTRY_PARAM, source.getCountry());
            converted = getSingleResult(query.getResultList());

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

    @Autowired
    private JpaAddressConverter addressConverter;

    @Test
    public void noConversion() {
        Address address = new JpaAddress();
        assertThat(addressConverter.convert(address), is(sameInstance(address)));
    }
View Full Code Here

        address.setLocality("Washington DC");
        address.setCountry("USA");
        address.setRegion("Washington DC");
        address.setPrimary(true);

        JpaAddress converted = addressConverter.convert(address);
        assertThat(converted, is(not(sameInstance(address))));
        assertThat(converted, is(instanceOf(JpaAddress.class)));
        assertThat(converted.getStreetAddress(), is(equalTo(address.getStreetAddress())));
        assertThat(converted.getLocality(), is(equalTo(address.getLocality())));
        assertThat(converted.getCountry(), is(equalTo(address.getCountry())));
        assertThat(converted.getRegion(), is(equalTo(address.getRegion())));
        assertThat(converted.getPrimary(), is(true));
    }
View Full Code Here

TOP

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

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.