Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.AppData


     * Simple test for dataset setup.
     */
    @Test
    public void testDatasetSetup()
    {
        AppData testAppData = jpaAppDataMapper.findById(new Long(testAppDataId));
        assertEquals("Person is not correct for retrieved AppData", testPersonId, testAppData.getPerson().getId());
        assertEquals("Viewcount is incorrect for retrieved AppData", "2", testAppData.getValues().get("viewcount"));
        assertEquals("Answer to question1answer is incorrect for retrieved AppData", "true", testAppData.getValues()
                .get("question1answer"));
    }
View Full Code Here


     * Test if data retrieved by Gadget and Person Id's is correct.
     */
    @Test
    public void testFindByAppAndPersonId()
    {
        AppData testAppData = jpaAppDataMapper.findOrCreateByPersonAndGadgetDefinitionIds(testGadgetDefinitionId,
                testOpenSocialPersonId);
        assertEquals("Person is not correct for retrieved AppData", testOpenSocialPersonId, testAppData.getPerson()
                .getOpenSocialId());
        assertEquals("GadgetDefinition is not correct for retrieved AppData", testGadgetDefinitionUrl, testAppData
                .getGadgetDefinition().getUrl());

    }
View Full Code Here

     * Testing insert capabilities.
     */
    @Test
    public void testInsert()
    {
        AppData appDataTestInstance = getNewAppDataObject();
        jpaAppDataMapper.insert(appDataTestInstance);
        assertTrue("Insert didn't work correctly, id is bad", appDataTestInstance.getId() > 0);
    }
View Full Code Here

     *             when an exception is encountered.
     */
    @Test
    public void testRemoveDataItem() throws Exception
    {
        AppData appDataTestInstance = jpaAppDataMapper.findById(testAppDataId);
        jpaAppDataMapper.deleteAppDataValueByKey(appDataTestInstance.getId(), "viewcount");
        jpaAppDataMapper.flush();
        getEntityManager().clear();
        AppData appDataTestInstanceRemoved = jpaAppDataMapper.findById(testAppDataId);
        assertFalse("Data was not removed", appDataTestInstanceRemoved.getValues().containsKey("viewcount"));
    }
View Full Code Here

     *             when an error is encountered.
     */
    @Test
    public void testRemoveDataKeyThatDoesntExist() throws Exception
    {
        AppData appDataTestInstance = jpaAppDataMapper.findById(testAppDataId);
        jpaAppDataMapper.deleteAppDataValueByKey(appDataTestInstance.getId(), "nonexistent");
        jpaAppDataMapper.flush();
        getEntityManager().clear();
        AppData appDataTestInstanceRemoved = jpaAppDataMapper.findById(testAppDataId);
        assertFalse("Data was not removed", appDataTestInstanceRemoved.getValues().containsKey("nonexistent"));
    }
View Full Code Here

     *             when an error is encountered.
     */
    @Test
    public void testRemoveDataKeyThatIsBad() throws Exception
    {
        AppData appDataTestInstance = jpaAppDataMapper.findById(testAppDataId);
        jpaAppDataMapper.deleteAppDataValueByKey(appDataTestInstance.getId(), "viewcount' OR 1=1");
        jpaAppDataMapper.flush();
        getEntityManager().clear();
        AppData appDataTestInstanceRemoved = jpaAppDataMapper.findById(testAppDataId);
        assertTrue("Data was removed with a bad key", appDataTestInstanceRemoved.getValues().containsKey("viewcount"));
    }
View Full Code Here

     * Test the ability to update the value of an app data item.
     */
    @Test
    public void testUpdateDataItem()
    {
        AppData appDataTestInstance = jpaAppDataMapper.findById(testAppDataId);
        Map<String, String> appDataValues = new HashMap<String, String>(appDataTestInstance.getValues());
        appDataValues.put("viewcount", "4");
        appDataTestInstance.setValues(appDataValues);
        jpaAppDataMapper.flush();
        getEntityManager().clear();
        AppData appDataTestInstanceUpdated = jpaAppDataMapper.findById(testAppDataId);
        assertTrue("Data was not removed", appDataTestInstanceUpdated.getValues().containsKey("viewcount"));
        assertEquals("Data was not updated", "4", appDataTestInstanceUpdated.getValues().get("viewcount"));
    }
View Full Code Here

    private AppData getNewAppDataObject()
    {
        Map<String, String> testDataValues = new HashMap<String, String>();
        testDataValues.put("favoritegame", "gearsofwar");
        testDataValues.put("firstpet", "snake");
        AppData testInputAppData = new AppData();
        testInputAppData.setValues(testDataValues);
        testInputAppData.setGadgetDefinition(new GadgetDefinition(testGadgetDefinitionUrl,
                UUID.randomUUID().toString(), new GalleryItemCategory("somecategory")));
        testInputAppData.setPerson(new Person("acole", "Augustus", "jay", "Cole", "Cole Train"));

        return testInputAppData;
    }
View Full Code Here

    {
        UpdateAppDataRequest parameters = (UpdateAppDataRequest) inActionContext.getParams();
        long applicationId = parameters.getApplicationId();
        String personId = parameters.getOpenSocialId();

        AppData outputAppData = null;
        AppData currentAppData = mapper.findOrCreateByPersonAndGadgetDefinitionIds(applicationId, personId);
        if (currentAppData != null)
        {
            HashMap<String, String> inputAppDataVals = parameters.getAppDataValues();
            if (inputAppDataVals != null)
            {
                Map<String, String> appDataVals = new HashMap<String, String>(currentAppData.getValues());
                for (Entry<String, String> currentAppDataValue : inputAppDataVals.entrySet())
                {
                    appDataVals.put(currentAppDataValue.getKey(), currentAppDataValue.getValue());
                }
                currentAppData.setValues(appDataVals);
                mapper.flush();
            }

            // delete cache
            log.info("Deleting the AppDataDTO cache for gadDef " + applicationId + ", open social id: " + personId);
View Full Code Here

    public AppDataDTO execute(final GetAppDataRequest inRequest)
    {
        long gadgetDefinitionId = inRequest.getApplicationId();
        String openSocialId = inRequest.getOpenSocialId();

        AppData appData = entityMapper.findOrCreateByPersonAndGadgetDefinitionIds(gadgetDefinitionId, openSocialId);
        return new AppDataDTO(openSocialId, gadgetDefinitionId, appData.getValues());
    }
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.AppData

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.