Package org.apache.rave.portal.model

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


    @Autowired
    private JpaApplicationDataConverter applicationDataConverter;

    @Test
    public void noConversion() {
        ApplicationData applicationData = new JpaApplicationData();
        assertThat(applicationDataConverter.convert(applicationData), is(sameInstance(applicationData)));
    }
View Full Code Here


        applicationData.setId("1");
        applicationData.setAppUrl("url");
        applicationData.setData(new HashMap<String, String>());
        applicationData.setUserId("userid");

        JpaApplicationData converted = applicationDataConverter.convert(applicationData);
        assertThat(converted, is(not(sameInstance(applicationData))));
        assertThat(converted, is(instanceOf(JpaApplicationData.class)));
        assertThat(converted.getId(), is(equalTo(applicationData.getId())));
        assertThat(converted.getEntityId().toString(), is(equalTo(applicationData.getId())));
        assertThat(converted.getAppUrl(), is(equalTo(applicationData.getAppUrl())));
        assertThat(converted.getData(), is(equalTo(applicationData.getData())));
        assertThat(converted.getUserId(), is(equalTo(applicationData.getUserId())));
    }
View Full Code Here

    public JpaApplicationData convert(ApplicationData source) {
        return source instanceof JpaApplicationData ? (JpaApplicationData) source : createEntity(source);
    }

    private JpaApplicationData createEntity(ApplicationData source) {
        JpaApplicationData converted = null;
        if (source != null) {
            converted = source.getId() == null ? new JpaApplicationData() : manager.find(JpaApplicationData.class, Long.parseLong(source.getId()));
            if(converted == null) {
                converted = new JpaApplicationData();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

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

    @Test
    public void get_valid() {
        JpaApplicationData applicationData = (JpaApplicationData) repository.get(VALID_APPLICATION_DATA_ID.toString());
        validateApplicationData(applicationData);
    }
View Full Code Here

        assertThat(applicationData, is(nullValue()));
    }

    @Test
    public void getApplicationData_byUserIdAndApplicationId_valid() {
        JpaApplicationData applicationData = (JpaApplicationData) repository.getApplicationData(VALID_USER_ID, VALID_APPLICATION_ID);
        validateApplicationData(applicationData);
    }
View Full Code Here

    @Test
    @Transactional
    @Rollback(true)
    public void save_newEntity() {
        ApplicationData applicationData = new JpaApplicationData(null, VALID_USER_ID, SECOND_VALID_APPLICATION_ID,
                validApplicationDataMap);

        JpaApplicationData saved = (JpaApplicationData)repository.save(applicationData);
        manager.flush();
        assertThat(saved.getEntityId(), is(notNullValue()));
    }
View Full Code Here

    @Test
    @Transactional
    @Rollback(true)
    public void save_existingEntity() {
        JpaApplicationData applicationData = new JpaApplicationData(VALID_APPLICATION_DATA_ID, VALID_USER_ID,
                VALID_APPLICATION_ID, new HashMap<String, String>());

        JpaApplicationData saved = (JpaApplicationData)repository.save(applicationData);
        manager.flush();
        assertThat(saved, is(not(sameInstance(applicationData))));
        assertThat(saved.getEntityId(), is(equalTo(applicationData.getEntityId())));
    }
View Full Code Here

    }

    @Override
    @Transactional
    public JpaApplicationData save(ApplicationData item) {
        JpaApplicationData jpaAppData = converter.convert(item);
        JpaSerializableApplicationData jpaSerializableApplicationData = getJpaSerializableApplicationData(jpaAppData);
        jpaSerializableApplicationData.serializeData();
        return saveOrUpdate(jpaSerializableApplicationData.getEntityId(), manager, jpaSerializableApplicationData);
    }
View Full Code Here

    }

    @Override
    @Transactional
    public JpaApplicationData save(ApplicationData item) {
        JpaApplicationData jpaAppData = converter.convert(item);
        JpaSerializableApplicationData jpaSerializableApplicationData = getJpaSerializableApplicationData(jpaAppData);
        jpaSerializableApplicationData.serializeData();
        return saveOrUpdate(jpaSerializableApplicationData.getEntityId(), manager, jpaSerializableApplicationData);
    }
View Full Code Here

    public JpaApplicationData convert(ApplicationData source) {
        return source instanceof JpaApplicationData ? (JpaApplicationData) source : createEntity(source);
    }

    private JpaApplicationData createEntity(ApplicationData source) {
        JpaApplicationData converted = null;
        if (source != null) {
            converted = manager.find(JpaApplicationData.class, source.getId() == null ? null : Long.parseLong(source.getId()));
            if (converted == null) {
                converted = new JpaApplicationData();
            }
            updateProperties(source, converted);
        }
        return converted;
    }
View Full Code Here

TOP

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

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.