Package com.impetus.kundera.graph

Examples of com.impetus.kundera.graph.Node


     */
    @Test
    public void testHandleMerge() throws IllegalArgumentException, InstantiationException, IllegalAccessException,
            InvocationTargetException, SecurityException, NoSuchMethodException
    {
        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);
       
        state.handleMerge(storeNode);

        Assert.assertEquals(ManagedState.class, storeNode.getCurrentNodeState().getClass());
        Assert.assertTrue(storeNode.isUpdate());
        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 testHandleDetach()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.DETACH);
        state.handleDetach(storeNode);

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

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

     * .
     */
    @Test
    public void testHandleClear()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.DETACH);
        state.handleClear(storeNode);

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

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

     * .
     */
    @Test
    public void testHandleClose()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.DETACH);
        state.handleClose(storeNode);

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

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

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

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

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

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

    // @Test
    public void testHandleRollback()
    {
        // Extended
        pc.setPersistenceContextType(PersistenceContextType.EXTENDED);
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleDetach(storeNode);

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

        for (Node childNode : storeNode.getChildren().values())
        {
            Assert.assertEquals(BillingCounter.class, childNode.getDataClass());
            Assert.assertEquals(ManagedState.class, childNode.getCurrentNodeState().getClass());
        }

        // Transactional
        pc.setPersistenceContextType(PersistenceContextType.TRANSACTION);
        storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleDetach(storeNode);

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

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

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

     * .
     */
    @Test
    public void testHandleGetReference()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleGetReference(storeNode);
        Assert.assertTrue(storeNode.getCurrentNodeState().getClass().equals(ManagedState.class));
    }
View Full Code Here

     * .
     */
    @Test
    public void testHandleContains()
    {
        Node storeNode = StoreBuilder.buildStoreNode(pc, state, CascadeType.PERSIST);
        state.handleContains(storeNode);
        Assert.assertTrue(storeNode.getCurrentNodeState().getClass().equals(ManagedState.class));
    }
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.