Package org.candlepin.model

Examples of org.candlepin.model.DistributorVersion


            .thenReturn("publicKey".getBytes());
        when(consumer.getUuid()).thenReturn("8auuid");
        when(consumer.getName()).thenReturn("consumer_name");
        when(consumer.getType()).thenReturn(new ConsumerType(ConsumerTypeEnum.CANDLEPIN));

        DistributorVersion dv = new DistributorVersion("test-dist-ver");
        Set<DistributorVersionCapability> dvcSet =
            new HashSet<DistributorVersionCapability>();
        dvcSet.add(new DistributorVersionCapability(dv, "capability-1"));
        dvcSet.add(new DistributorVersionCapability(dv, "capability-2"));
        dvcSet.add(new DistributorVersionCapability(dv, "capability-3"));
        dv.setCapabilities(dvcSet);
        List<DistributorVersion> dvList = new ArrayList<DistributorVersion>();
        dvList.add(dv);
        when(dvc.findAll()).thenReturn(dvList);

        // FINALLY test this badboy
View Full Code Here


     */
    @DELETE
    @Path("/{id}")
    public void delete(@PathParam("id") String id,
        @Context Principal principal) {
        DistributorVersion dv = curator.findById(id);
        if (dv != null) {
            curator.delete(dv);
        }
    }
View Full Code Here

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public DistributorVersion create(DistributorVersion dv,
        @Context Principal principal) {
        DistributorVersion existing = curator.findByName(dv.getName());
        if (existing != null) {
            throw new BadRequestException(
                i18n.tr("A distributor version with name {0} " +
                        "already exists", dv.getName()));
        }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    @Path("/{id}")
    public DistributorVersion update(@PathParam("id") String id,
        DistributorVersion dv,
        @Context Principal principal) {
        DistributorVersion existing = verifyAndLookupDistributorVersion(id);
        existing.setDisplayName(dv.getDisplayName());
        existing.setCapabilities(dv.getCapabilities());
        curator.merge(existing);
        return existing;
    }
View Full Code Here

        curator.merge(existing);
        return existing;
    }

    private DistributorVersion verifyAndLookupDistributorVersion(String id) {
        DistributorVersion dv = curator.findById(id);

        if (dv == null) {
            throw new NotFoundException(i18n.tr("No such distributor version: {0}",
                id));
        }
View Full Code Here

                        {
                            put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES,
                                    "false");
                        }
                    }));
            DistributorVersion dv = om.readValue(
                new FileInputStream("/tmp/" + filename),
                DistributorVersion.class);
            assertNotNull(dv);
            assertEquals("test-dist-ver", dv.getName());
            assertEquals(3, dv.getCapabilities().size());
        }
View Full Code Here

    public void importDistributorVersionUpdate() throws Exception {
        DistributorVersionCurator dvc = mock(DistributorVersionCurator.class);
        Importer i = new Importer(null, null, null, null, null, null, null,
            null, null, null, null, null, null, i18n, dvc, null);
        when(dvc.findByName("test-dist-ver")).thenReturn(
            new DistributorVersion("test-dist-ver"));
        File[] distVer = new File[1];
        distVer[0] = new File("target/test/resources/upstream/dist-ver.json");

        i.importDistributorVersions(distVer);
View Full Code Here

        this.curator = curator;
    }

    public DistributorVersion createObject(ObjectMapper mapper, Reader reader)
        throws IOException {
        DistributorVersion distributorVersion = mapper.readValue(reader,
            DistributorVersion.class);
        distributorVersion.setId(null);
        for (DistributorVersionCapability dvc : distributorVersion.getCapabilities()) {
            dvc.setId(null);
        }
        return distributorVersion;
    }
View Full Code Here

     * @param distVers Set of Distributor Versions.
     */
    public void store(Set<DistributorVersion> distVers) {
        log.debug("Creating/updating distributor versions");
        for (DistributorVersion distVer : distVers) {
            DistributorVersion existing = curator.findByName(distVer.getName());
            if (existing == null) {
                curator.create(distVer);
                log.debug("Created distributor version: " + distVer.getName());
            }
            else {
                existing.setCapabilities(distVer.getCapabilities());
                existing.setDisplayName(distVer.getDisplayName());
                curator.merge(existing);
                log.debug("Updating distributor version: " + distVer.getName());
            }
        }
    }
View Full Code Here

            if (update.getCapabilities() != null) {
                change = update.getCapabilities().equals(existing.getCapabilities());
                existing.setCapabilities(update.getCapabilities());
            }
            else if (update.getFact("distributor_version") !=  null) {
                DistributorVersion dv = distributorVersionCurator.findByName(
                    update.getFact("distributor_version"));
                if (dv != null) {
                    Set<ConsumerCapability> ccaps = new HashSet<ConsumerCapability>();
                    for (DistributorVersionCapability dvc : dv.getCapabilities()) {
                        ConsumerCapability cc =
                            new ConsumerCapability(existing, dvc.getName());
                        ccaps.add(cc);
                    }
                    existing.setCapabilities(ccaps);
View Full Code Here

TOP

Related Classes of org.candlepin.model.DistributorVersion

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.