Package org.apache.jackrabbit.ocm.testmodel.collection

Examples of org.apache.jackrabbit.ocm.testmodel.collection.Main


        assertNotNull(firstA.getUuid());
        assertNotNull(secondA.getUuid());
        assertNotNull(thirdA.getUuid());


        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", secondA);
       


        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("DefaultMapConverterImpl failed to store or reload objects in map property: referencedMap", 2, main.getReferenceMap().size());
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFirst"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keySecond"));
        assertNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyThird"));


        main.getReferenceMap().put("keyThird", thirdA);
        ocm.update(main);
        main = (Main) ocm.getObject(main.getPath());
        assertEquals("DefaultMapConverterImpl failed to store or reload objects in map property: referencedMap", 3, main.getReferenceMap().size());
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFirst"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keySecond"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyThird"));
    }
View Full Code Here


        assertNotNull(secondA.getUuid());
        assertNotNull(thirdA.getUuid());
        assertNotNull(fourthA.getUuid());


        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", secondA);
        main.getReferenceMap().put("keyThird", thirdA);



        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("DefaultMapConverterImpl failed to store or reload objects in map property: referencedMap", 3, main.getReferenceMap().size());
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFirst"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keySecond"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyThird"));
        assertNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFourth"));


        main.getReferenceMap().put("keyFourth", fourthA);
        main.getReferenceMap().remove("keyFirst");
        ocm.update(main);
        main = (Main) ocm.getObject(main.getPath());
       
        assertEquals("DefaultMapConverterImpl failed to store or reload objects in map property: referencedMap", 3, main.getReferenceMap().size());
        assertNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFirst"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keySecond"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyThird"));
        assertNotNull("DefaultMapConverterImpl failed to store objects in map", main.getReferenceMap().get("keyFourth"));
    }
View Full Code Here

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository with null hashmap
            // --------------------------------------------------------------------------------

            Main main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            ocm.insert(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            assertNull("HashMap is not null", main.getHashMapElement());

            // --------------------------------------------------------------------------------
            // Update an object graph in the repository
            // --------------------------------------------------------------------------------

            main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            HashMapElement hashMapElement = new HashMapElement();
            Element e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);

            Element e2 = new Element();
            e2.setId("e2");
            e2.setText("Element 2");
            hashMapElement.addObject(e2);

            main.setHashMapElement(hashMapElement);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertNotNull("main.getHashMap() is null", main.getHashMapElement());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            Map map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", ((Element) map.get("e1")).getText().equals("Element 1"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            hashMapElement = new HashMapElement();
            e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);

            e2 = new Element();
            e2.setId("e3");
            e2.setText("Element 3");
            hashMapElement.addObject(e2);

            Element e3 = new Element();
            e3.setId("e4");
            e3.setText("Element 4");
            hashMapElement.addObject(e3);
            main.setHashMapElement(hashMapElement);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            assertNotNull("main.getElements() is null", main.getHashMapElement());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", ((Element) map.get("e4")).getText().equals("Element 4"));

        }
        catch (Exception e)
        {
View Full Code Here

        assertNotNull(firstA.getUuid());
        assertNotNull(secondA.getUuid());
        assertNotNull(thirdA.getUuid());


        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", secondA);
        main.getReferenceMap().put("keyThird", thirdA);


        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("Referenced objects in store were not retrieved.", 3, main.getReferenceMap().size());
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyFirst"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keySecond"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyThird"));


        assertEquals("the first", main.getReferenceMap().get("keyFirst").getStringData());
        assertEquals("the second", main.getReferenceMap().get("keySecond").getStringData());
        assertEquals("the third", main.getReferenceMap().get("keyThird").getStringData());

    }
View Full Code Here

        firstA = (A) ocm.getObject(firstA.getPath());

        assertNotNull(firstA.getUuid());

        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", firstA);
        main.getReferenceMap().put("keyThird", firstA);


        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("Referenced objects in store were not retrieved.", 3, main.getReferenceMap().size());
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyFirst"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keySecond"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyThird"));


        assertEquals("the data", main.getReferenceMap().get("keyFirst").getStringData());
        assertEquals("the data", main.getReferenceMap().get("keySecond").getStringData());
        assertEquals("the data", main.getReferenceMap().get("keyThird").getStringData());


    }
View Full Code Here

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository with null hashmap
            // --------------------------------------------------------------------------------

            Main main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            ocm.insert(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            assertNull("HashMap is not null", main.getHashMapElement());

            // --------------------------------------------------------------------------------
            // Update an object graph in the repository
            // --------------------------------------------------------------------------------

            main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            HashMapElement hashMapElement = new HashMapElement();
            Element e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);

            Element e2 = new Element();
            e2.setId("e2");
            e2.setText("Element 2");
            hashMapElement.addObject(e2);

            main.setHashMapElement(hashMapElement);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertNotNull("main.getHashMap() is null", main.getHashMapElement());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            Map map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", ((Element) map.get("e1")).getText().equals("Element 1"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            hashMapElement = new HashMapElement();
            e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);

            e2 = new Element();
            e2.setId("e3");
            e2.setText("Element 3");
            hashMapElement.addObject(e2);

            Element e3 = new Element();
            e3.setId("e4");
            e3.setText("Element 4");
            hashMapElement.addObject(e3);
            main.setHashMapElement(hashMapElement);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            assertNotNull("main.getElements() is null", main.getHashMapElement());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", ((Element) map.get("e4")).getText().equals("Element 4"));

        }
        catch (Exception e)
        {
View Full Code Here

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository with null hashmap
            // --------------------------------------------------------------------------------

            Main main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            ocm.insert(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            assertNull("HashMap is not null", main.getHashMapElement());
            assertNull("Map is not null", main.getMap());

            // --------------------------------------------------------------------------------
            // Update an object graph in the repository
            // --------------------------------------------------------------------------------

            main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            HashMapElement hashMapElement = new HashMapElement();
            Map<String, Element> map = new HashMap<String, Element>();

            Element e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);
            map.put("keyE1", e1);

            Element e2 = new Element();
            e2.setId("e2");
            e2.setText("Element 2");
            hashMapElement.addObject(e2);
            map.put("keyE2", e2);

            main.setHashMapElement(hashMapElement);
            main.setMap(map);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            assertNotNull("main.getHashMap() is null", main.getHashMapElement());
            assertNotNull("main.getHashMap() is null", main.getMap());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", map.get("e1").getText().equals("Element 1"));
            assertTrue("Incorrect para element", map.get("e2").getText().equals("Element 2"));
           
            map = main.getMap();
            assertTrue("Incorrect para element", map.get("keyE1").getText().equals("Element 1"));
            assertTrue("Incorrect para element", map.get("keyE2").getText().equals("Element 2"));

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            hashMapElement = new HashMapElement();
            map = new HashMap<String, Element>();

            e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            hashMapElement.addObject(e1);
            map.put("keyE1", e1);

            e2 = new Element();
            e2.setId("e3");
            e2.setText("Element 3");
            hashMapElement.addObject(e2);
            map.put("keyE3", e2);

            Element e3 = new Element();
            e3.setId("e4");
            e3.setText("Element 4");
            hashMapElement.addObject(e3);
            map.put("keyE4", e3);

            main.setHashMapElement(hashMapElement);
            main.setMap(map);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            assertNotNull("main.getElements() is null", main.getHashMapElement());
            assertTrue("Incorrect text", main.getText().equals("Main text"));
            map = (Map) main.getHashMapElement().getObjects();
            assertTrue("Incorrect para element", map.get("e4").getText().equals("Element 4"));
            assertTrue("Incorrect para element", map.get("e4").getText().equals("Element 4"));
           
            map = main.getMap();
            assertTrue("Incorrect para element", map.get("keyE4").getText().equals("Element 4"));
            assertTrue("Incorrect para element", map.get("keyE4").getText().equals("Element 4"));
        }
        catch (Exception e)
        {
View Full Code Here

            // --------------------------------------------------------------------------------
            // Create and store an object graph in the repository
          // with a null value for the arraylist
            // --------------------------------------------------------------------------------

            Main main = new Main();
            main.setPath("/test");
            main.setText("Main text");

            ocm.insert(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            ArrayListElement arrayList = main.getArrayListElement();
            List<Element> list = main.getList();
            assertNull("main.getArrayListElement is not null", arrayList );
            assertNull("main.getList is not null", list );

            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------

            ArrayListElement arrayListElement = new ArrayListElement();
            list = new ArrayList<Element>();

            Element e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            arrayListElement.addObject(e1);
            list.add(e1);

            Element e2 = new Element();
            e2.setId("e2");
            e2.setText("Element 2");
            arrayListElement.addObject(e2);
            list.add(e2);

            main.setArrayListElement(arrayListElement);
            main.setList(list);
            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            arrayList = main.getArrayListElement();
            list = main.getList();
            assertNotNull("main.getArrayListElemnt is null", arrayList );
            assertNotNull("main.getList is null", list );
            Collection<Element> objects = (Collection<Element>) arrayList.getObjects();
            Element[] elements = (Element[]) objects.toArray(new Element[objects.size()]);
            assertTrue("Incorrect para element", elements[0].getText().equals("Element 1"));
            assertTrue("Incorrect para element", list.get(0).getText().equals("Element 1"));



            // --------------------------------------------------------------------------------
            // Update the object
            // --------------------------------------------------------------------------------
            arrayListElement = new ArrayListElement();
            list = new ArrayList<Element>();
            e1 = new Element();
            e1.setId("e1");
            e1.setText("Element 1");
            arrayListElement.addObject(e1);
            list.add(e1);

            e2 = new Element();
            e2.setId("e3");
            e2.setText("Element 3");
            arrayListElement.addObject(e2);
            list.add(e2);

            Element e3 = new Element();
            e3.setId("e4");
            e3.setText("Element 4");
            arrayListElement.addObject(e3);
            list.add(e3);

            main.setArrayListElement(arrayListElement);
            main.setList(list);

            ocm.update(main);
            ocm.save();

            // --------------------------------------------------------------------------------
            // Get the object
            // --------------------------------------------------------------------------------
            main = (Main) ocm.getObject( "/test");
            arrayList = main.getArrayListElement();
            list = main.getList();
            assertNotNull("main.getArrayListElement() is null", arrayList );
            assertNotNull("main.getList() is null", list );
            objects = (Collection<Element>) arrayList.getObjects();
            elements = (Element[]) objects.toArray(new Element[objects.size()]);
            assertTrue("Incorrect element", elements[2].getText().equals("Element 4"));
View Full Code Here

        assertNotNull(firstA.getUuid());
        assertNotNull(secondA.getUuid());
        assertNotNull(thirdA.getUuid());


        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", secondA);
        main.getReferenceMap().put("keyThird", thirdA);


        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("Referenced objects in store were not retrieved.", 3, main.getReferenceMap().size());
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyFirst"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keySecond"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyThird"));


        assertEquals("the first", main.getReferenceMap().get("keyFirst").getStringData());
        assertEquals("the second", main.getReferenceMap().get("keySecond").getStringData());
        assertEquals("the third", main.getReferenceMap().get("keyThird").getStringData());

    }
View Full Code Here

        firstA = (A) ocm.getObject(firstA.getPath());

        assertNotNull(firstA.getUuid());

        Main main = new Main();
        main.setPath("/test/1");
        main.getReferenceMap().put("keyFirst", firstA);
        main.getReferenceMap().put("keySecond", firstA);
        main.getReferenceMap().put("keyThird", firstA);


        ocm.insert(main);
        main = (Main) ocm.getObject(main.getPath());

        assertEquals("Referenced objects in store were not retrieved.", 3, main.getReferenceMap().size());
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyFirst"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keySecond"));
        assertNotNull("Reference could not be retrieved by its original key", main.getReferenceMap().get("keyThird"));


        assertEquals("the data", main.getReferenceMap().get("keyFirst").getStringData());
        assertEquals("the data", main.getReferenceMap().get("keySecond").getStringData());
        assertEquals("the data", main.getReferenceMap().get("keyThird").getStringData());


    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.testmodel.collection.Main

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.