Package com.impetus.kundera.graph

Examples of com.impetus.kundera.graph.Node


    @Test
    public void testHandleFlush()
    {
        try
        {
            Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.REFRESH);
            state.handleFlush(storeNode);
            Assert.fail("Exception should be thrown because client is not available");
        }
        catch (Exception e)
        {
View Full Code Here


     * .
     */
    @Test
    public void testInitialize()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.initialize(storeNode);
        Assert.assertNotNull(pc);
    }
View Full Code Here

     */
    @Test
    public void testHandlePersist() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
            InstantiationException, IllegalAccessException, InvocationTargetException
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("kunderatest");
        Constructor constructor = PersistenceDelegator.class.getDeclaredConstructor(KunderaMetadata.class,
                PersistenceCache.class);
        constructor.setAccessible(true);
        PersistenceDelegator pd = (PersistenceDelegator) constructor.newInstance(
                ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), new PersistenceCache());

        storeNode.setPersistenceDelegator(pd);

        state.handlePersist(storeNode);

        Assert.assertEquals(ManagedState.class, storeNode.getCurrentNodeState().getClass());
        Assert.assertTrue(storeNode.isDirty());
        Assert.assertNotNull(storeNode.getPersistenceCache().getMainCache()
                .getNodeFromCache(storeNode.getNodeId(), null));

        // for (Node childNode : storeNode.getChildren().values())
        // {
        // Assert.assertEquals(BillingCounter.class, childNode.getDataClass());
        // Assert.assertEquals(ManagedState.class,
View Full Code Here

     * .
     */
    @Test
    public void testHandleRemove()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.REMOVE);
        state.handleRemove(storeNode);

        Assert.assertEquals(TransientState.class, storeNode.getCurrentNodeState().getClass());

        for (Node childNode : storeNode.getChildren().values())
        {
            Assert.assertEquals(BillingCounter.class, childNode.getDataClass());
            Assert.assertEquals(TransientState.class, childNode.getCurrentNodeState().getClass());
        }
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleRefresh()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.REFRESH);
        try
        {
            state.handleRefresh(storeNode);
            Assert.fail("Refresh operation in Transient state should have thrown exception");
        }
View Full Code Here

     */
    @Test
    public void testHandleMerge() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
            InstantiationException, IllegalAccessException, InvocationTargetException
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.MERGE);

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("kunderatest");
        Constructor constructor = PersistenceDelegator.class.getDeclaredConstructor(KunderaMetadata.class,
                PersistenceCache.class);
        constructor.setAccessible(true);
        PersistenceDelegator pd = (PersistenceDelegator) constructor.newInstance(
                ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance(), new PersistenceCache());

        storeNode.setPersistenceDelegator(pd);

        Object data1 = storeNode.getData();
        state.handleMerge(storeNode);
        Object data2 = storeNode.getData();
        Assert.assertTrue(DeepEquals.deepEquals(data1, data2));
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleDetach()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.DETACH);
        state.handleDetach(storeNode);
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleClose()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleClose(storeNode);
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleLock()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleLock(storeNode);
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleCommit()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleCommit(storeNode);
    }
View Full Code Here

TOP

Related Classes of com.impetus.kundera.graph.Node

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.