Package javax.persistence

Examples of javax.persistence.EntityManager.createNamedQuery()


        PackageTypeBehavior mockPackageTypeBehavior = mock(PackageTypeBehavior.class);
        PowerMockito.mockStatic(ContentManagerHelper.class);
        when(ContentManagerHelper.getPackageTypeBehavior(1)).thenReturn(mockPackageTypeBehavior);

        when(mockEntityManager.createNamedQuery(eq(Architecture.QUERY_FIND_BY_NAME))).thenReturn(mockQuery);
        when(mockEntityManager.createNamedQuery(eq(Package.QUERY_FIND_BY_NAME_PKG_TYPE_ID))).thenReturn(mockQuery);

        ContentManagerLocal mockContentManager = mock(ContentManagerLocal.class);
        Package mockPackage = mock(Package.class);
        when(mockContentManager.persistPackage(isNotNull(Package.class))).thenReturn(mockPackage);
       
View Full Code Here


        //tell the method story as it happens: mock dependencies and make them
        //behave in a way to get the method under test to completion.
        EntityManager mockEntityManager = mock(EntityManager.class);

        Query mockQuery = mock(Query.class);
        when(mockEntityManager.createNamedQuery(eq(PackageVersion.QUERY_FIND_BY_PACKAGE_VER_ARCH))).thenReturn(
            mockQuery);
        List mockList = mock(List.class);
        when(mockQuery.getResultList()).thenReturn(mockList);
        when(mockList.size()).thenReturn(1);
        PackageVersion mockPackageVersion = mock(PackageVersion.class);
View Full Code Here

        //tell the method story as it happens: mock dependencies and make them
        //behave in a way to get the method under test to completion.
        EntityManager mockEntityManager = mock(EntityManager.class);

        Query mockQuery = mock(Query.class);
        when(mockEntityManager.createNamedQuery(eq(PackageVersion.QUERY_FIND_BY_PACKAGE_VER_ARCH))).thenReturn(
            mockQuery);
        List mockList = mock(List.class);
        when(mockQuery.getResultList()).thenReturn(mockList);
        when(mockList.size()).thenReturn(1);
        PackageVersion mockPackageVersion = mock(PackageVersion.class);
View Full Code Here

        //tell the method story as it happens: mock dependencies and make them
        //behave in a way to get the method under test to completion.
        EntityManager mockEntityManager = mock(EntityManager.class);

        Query mockQuery = mock(Query.class);
        when(mockEntityManager.createNamedQuery(eq(PackageVersion.QUERY_FIND_BY_PACKAGE_VER_ARCH))).thenReturn(
            mockQuery);
        List mockList = mock(List.class);
        when(mockQuery.getResultList()).thenReturn(mockList);
        when(mockList.size()).thenReturn(2);
        PackageVersion mockPackageVersion = mock(PackageVersion.class);
View Full Code Here

        //tell the method story as it happens: mock dependencies and make them
        //behave in a way to get the method under test to completion.
        EntityManager mockEntityManager = mock(EntityManager.class);

        Query mockQuery = mock(Query.class);
        when(mockEntityManager.createNamedQuery(eq(PackageVersion.QUERY_FIND_BY_PACKAGE_VER_ARCH))).thenReturn(
            mockQuery);
        List mockList = mock(List.class);
        when(mockQuery.getResultList()).thenReturn(mockList);
        when(mockList.size()).thenReturn(1);
        final PackageVersion mockPackageVersion = mock(PackageVersion.class);
View Full Code Here

            em.persist(repo1);
            em.persist(repo2);
            assert repo1.getId() > 0;
            assert repo2.getId() > 0;

            Query q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
            q.setParameter("id", repo1.getId());
            assert q.getResultList().size() == 0 : "should not have repo1 mapping in the db yet";
            q.setParameter("id", repo2.getId());
            assert q.getResultList().size() == 0 : "should not have repo2 mapping in the db yet";
View Full Code Here

            BundleVersionRepo bvr1 = new BundleVersionRepo(bundleVersion, repo1);
            BundleVersionRepo bvr2 = new BundleVersionRepo(bundleVersion, repo2);
            em.persist(bvr1);
            em.persist(bvr2);

            q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_REPO_ID_NO_FETCH);
            q.setParameter("id", repo1.getId());
            assert q.getResultList().size() == 1;
            assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion()
                .equals(bundleVersion);
            assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo1);
View Full Code Here

            assert q.getResultList().size() == 1;
            assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getBundleVersion()
                .equals(bundleVersion);
            assert ((BundleVersionRepo) q.getSingleResult()).getBundleVersionRepoPK().getRepo().equals(repo2);

            q = em.createNamedQuery(BundleVersionRepo.QUERY_FIND_BY_BUNDLE_VERSION_ID_NO_FETCH);
            q.setParameter("id", bundleVersion.getId());
            List<BundleVersionRepo> resultList = q.getResultList();
            assert resultList.size() == 2;
            BundleVersionRepoPK pk1 = new BundleVersionRepoPK(bundleVersion, repo1);
            BundleVersionRepoPK pk2 = new BundleVersionRepoPK(bundleVersion, repo2);
View Full Code Here

            assert id > 0;
            assert bundle.getBundleType().getId() != 0 : "bundleType should have been cascade persisted too";

            BundleVersion bv = new BundleVersion(name, "1.0.0.BETA", bundle, recipe);
            bv.setVersionOrder(777);
            Query q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
            q.setParameter("name", bv.getName());
            assert q.getResultList().size() == 0; // not in the db yet

            em.persist(bv);
            id = bv.getId();
View Full Code Here

            em.persist(bv);
            id = bv.getId();
            assert id > 0;

            q = em.createNamedQuery(BundleVersion.QUERY_FIND_BY_NAME);
            q.setParameter("name", bv.getName());
            assert q.getResultList().size() == 1;
            assert ((BundleVersion) q.getSingleResult()).getName().equals(bv.getName());

            BundleVersion bvFind = em.find(BundleVersion.class, id);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.