Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.PackageVersion


        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);
        when(mockList.get(eq(0))).thenReturn(mockPackageVersion);

        //create object to test and inject required dependencies
        ContentManagerBean objectUnderTest = new ContentManagerBean();
        Field[] fields = ContentManagerBean.class.getDeclaredFields();

        for (Field field : fields) {
            if (field.getName().equals("entityManager")) {
                field.setAccessible(true);
                field.set(objectUnderTest, mockEntityManager);
                field.setAccessible(false);
            }
        }

        //run the code to be tested
        PackageVersion result = objectUnderTest.createPackageVersionWithDisplayVersion(mockSubject, packageName,
            packageTypeID, version, displayVersion, architectureId, packageBitStream);

        //verify the results (Assert and Mock Verification)
        verify(mockList, times(1)).size();
        verify(mockList, times(1)).get(eq(0));
View Full Code Here


        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);
        when(mockList.get(eq(0))).thenReturn(mockPackageVersion);

        when(mockPackageVersion.getId()).thenReturn(0);
        ContentManagerLocal mockContentManager = mock(ContentManagerLocal.class);
        when(mockContentManager.persistPackageVersion(any(PackageVersion.class))).thenAnswer(
            new Answer<PackageVersion>() {
                public PackageVersion answer(InvocationOnMock invocation) throws Throwable {
                    Object[] args = invocation.getArguments();
                    return (PackageVersion) args[0];
                }
            });

        when(mockEntityManager.find(eq(PackageVersion.class), eq(0))).thenAnswer(new Answer<PackageVersion>() {
            public PackageVersion answer(InvocationOnMock invocation) throws Throwable {
                return mockPackageVersion;
            }
        });

        Package mockPackage = mock(Package.class);
        when(mockPackageVersion.getGeneralPackage()).thenReturn(mockPackage);
        Architecture mockArchitecture = mock(Architecture.class);
        when(mockPackageVersion.getArchitecture()).thenReturn(mockArchitecture);
        when(mockPackageVersion.getExtraProperties()).thenReturn(null);

        //create object to test and inject required dependencies
        ContentManagerBean objectUnderTest = new ContentManagerBean();
        Field[] fields = ContentManagerBean.class.getDeclaredFields();

        for (Field field : fields) {
            if (field.getName().equals("entityManager")) {
                field.setAccessible(true);
                field.set(objectUnderTest, mockEntityManager);
                field.setAccessible(false);
            }
            else if (field.getName().equals("contentManager")) {
                field.setAccessible(true);
                field.set(objectUnderTest, mockContentManager);
                field.setAccessible(false);
            }
        }

        //run the code to be tested
        PackageVersion result = objectUnderTest.createPackageVersionWithDisplayVersion(mockSubject, packageName,
            packageTypeID, version, displayVersion, architectureId, packageBitStream);

        //verify the results (Assert and Mock Verification)
        verify(mockList, times(1)).size();
        verify(mockList, times(1)).get(eq(0));
View Full Code Here

            ContentManagerRemote contentManager = remoteClient.getProxy(ContentManagerRemote.class);

            ContentUploader contentUploader = new ContentUploader(contentManager);
            String temporaryContentHandle = contentUploader.upload(file);

            PackageVersion pv = contentManager.createPackageVersionWithDisplayVersion(remoteClient.getSubject(),
                oldPackage.getPackageVersion().getGeneralPackage().getName(), oldPackage.getPackageVersion()
                    .getGeneralPackage().getPackageType().getId(), packageVersion, displayVersion, oldPackage
                    .getPackageVersion().getArchitecture().getId(), temporaryContentHandle);

            contentManager.deployPackagesWithNote(remoteClient.getSubject(), new int[] { resourceClientProxy.getId() },
                new int[] { pv.getId() }, "CLI deployment request");
        }
View Full Code Here

    public void testSerialization() {
        List<Serializable> objects = new ArrayList<Serializable>();
        Serializable[] simpleObjects = new Serializable[] { new AvailabilityReport("fakeAgent"), new PackageType(),
            new Architecture(), new Repo(), new ContentServiceRequest(), new ContentSource(), new ContentSourceType(),
            new InstalledPackage(), new Package(), new PackageInstallationStep(), new PackageType(),
            new PackageVersion() };
        objects.addAll(Arrays.asList(simpleObjects));

        ResourceType resourceType = new ResourceType("name", "plugin", ResourceCategory.PLATFORM, null);
        Resource resource = new Resource("key", "name", resourceType);
View Full Code Here

        ListGridRecord[] records = new ListGridRecord[files.size()];

        int i = 0;
        for (BundleFile file : files) {
            ListGridRecord record = new ListGridRecord();
            PackageVersion packageVersion = file.getPackageVersion();

            record.setAttribute(ID, file.getId());
            record.setAttribute(NAME, returnValueOrUnknown(packageVersion.getFileName()));
            record.setAttribute(MD5, returnValueOrUnknown(packageVersion.getMD5()));
            record.setAttribute(SHA256, returnValueOrUnknown(packageVersion.getSHA256()));
            record.setAttribute(VERSION, returnValueOrUnknown(packageVersion.getVersion()));

            Long size = packageVersion.getFileSize();
            if (size != null) {
                record.setAttribute(FILESIZE,
                    MeasurementConverterClient.format(size.doubleValue(), MeasurementUnits.BYTES, true));
            } else {
                record.setAttribute(FILESIZE, MSG.common_val_na());
View Full Code Here

            Resource resource = new Resource("testCSResource", "testCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testCSInsertArch");
            PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
            ContentSource cs = new ContentSource("testCSContentSource", cst);

            Configuration config = new Configuration();
            config.put(new PropertySimple("one", "oneValue"));
View Full Code Here

            Resource resource = new Resource("testCSResource", "testCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testCSInsertArch");
            PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
            cst.setDefaultSyncSchedule(null);
            ContentSource cs = new ContentSource("testCSContentSource", cst);
            cs.setSyncSchedule(null);
View Full Code Here

            Resource resource = new Resource("testCSResource", "testCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testCSInsertArch");
            PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
            cst.setDefaultSyncSchedule("");
            ContentSource cs = new ContentSource("testCSContentSource", cst);
            cs.setSyncSchedule("");
View Full Code Here

            Resource resource = new Resource("testCSResource", "testCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testCSInsertArch");
            PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
            ContentSource cs = new ContentSource("testCSContentSource", cst);

            Configuration config = new Configuration();
            config.put(new PropertySimple("one", "oneValue"));
View Full Code Here

            Resource resource = new Resource("testCSResource", "testCSResource", rt);
            resource.setUuid("" + new Random().nextInt());
            Architecture arch = new Architecture("testCSInsertArch");
            PackageType pt = new PackageType("testCSInsertPT", resource.getResourceType());
            Package pkg = new Package("testCSInsertPackage", pt);
            PackageVersion pv = new PackageVersion(pkg, "version", arch);
            ContentSourceType cst = new ContentSourceType("testCSContentSourceType");
            cst.setDefaultSyncSchedule(null);
            ContentSource cs = new ContentSource("testCSContentSource", cst);
            cs.setSyncSchedule(null);
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.PackageVersion

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.