Package org.candlepin.resource

Examples of org.candlepin.resource.OwnerResource


        ConsumerType ueberCertType = new ConsumerType(ConsumerTypeEnum.UEBER_CERT);
        consumerTypeCurator.create(ueberCertType);
        contentOverrideValidator = injector.getInstance(ContentOverrideValidator.class);

        or = new OwnerResource(ownerCurator,
            null, null, consumerCurator, null, i18n, null, null, null,
            null, null, poolManager, null, null, null, subAdapter,
            null, consumerTypeCurator, entCertCurator, entitlementCurator,
            ueberCertGenerator, null, null, contentOverrideValidator,
            serviceLevelValidator, null);
View Full Code Here


        when(ak.getName()).thenReturn("testKey");
        when(akc.lookupForOwner(eq("testKey"), eq(o))).thenReturn(akOld);
        when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);

        OwnerResource or = new OwnerResource(oc,
            null, akc, null, null, i18n, null, null, null,
            null, null, null, null, null, null, null,
            null, null, null, null, null, null, null, contentOverrideValidator,
            serviceLevelValidator, null);
        or.createActivationKey("testOwner", ak);
    }
View Full Code Here

    @Test
    public void testImportRecordSuccessWithFilename()
        throws IOException, ImporterException {
        Importer importer = mock(Importer.class);
        EventSink es = mock(EventSink.class);
        OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, null,
            null, null, null, i18n, es, null, null, null, importer, null, null,
            null, importRecordCurator, null, null, null, null, null,
            null, null, null, contentOverrideValidator,
            serviceLevelValidator, null);

        MultipartInput input = mock(MultipartInput.class);
        InputPart part = mock(InputPart.class);
        File archive = mock(File.class);
        List<InputPart> parts = new ArrayList<InputPart>();
        parts.add(part);
        MultivaluedMap<String, String> mm = new MultivaluedMapImpl<String, String>();
        List<String> contDis = new ArrayList<String>();
        contDis.add("form-data; name=\"upload\"; filename=\"test_file.zip\"");
        mm.put("Content-Disposition", contDis);

        when(input.getParts()).thenReturn(parts);
        when(part.getHeaders()).thenReturn(mm);
        when(part.getBody(any(GenericType.class))).thenReturn(archive);
        when(importer.loadExport(eq(owner), any(File.class), any(ConflictOverrides.class)))
            .thenReturn(new HashMap<String, Object>());

        thisOwnerResource.importManifest(owner.getKey(), new String [] {}, input);
        List<ImportRecord> records = importRecordCurator.findRecords(owner);
        ImportRecord ir = records.get(0);
        assertEquals("test_file.zip", ir.getFileName());
        assertEquals(owner, ir.getOwner());
        assertEquals(ImportRecord.Status.SUCCESS, ir.getStatus());
View Full Code Here

    public void testImportRecordDeleteWithLogging()
        throws IOException, ImporterException {
        EventSink es = mock(EventSink.class);
        ExporterMetadataCurator ec = mock(ExporterMetadataCurator.class);
        SubscriptionCurator sc = mock(SubscriptionCurator.class);
        OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, sc,
            null, null, null, i18n, es, null, null, null, null, null, ec,
            null, importRecordCurator, null, null, null, null, null,
            null, null, null, contentOverrideValidator,
            serviceLevelValidator, null);

        ExporterMetadata metadata = new ExporterMetadata();
        when(ec.lookupByTypeAndOwner(ExporterMetadata.TYPE_PER_USER, owner))
            .thenReturn(metadata);
        when(sc.listByOwner(owner)).thenReturn(new ArrayList<Subscription>());

        thisOwnerResource.undoImports(owner.getKey(),
            new UserPrincipal("JarJarBinks", null, true));
        List<ImportRecord> records = importRecordCurator.findRecords(owner);
        assertTrue(records.size() == 1);
        ImportRecord ir = records.get(0);
        assertTrue(ir.getStatus() == ImportRecord.Status.DELETE);
View Full Code Here

    @Test
    public void testImportRecordFailureWithFilename()
        throws IOException, ImporterException {
        Importer importer = mock(Importer.class);
        EventSink es = mock(EventSink.class);
        OwnerResource thisOwnerResource = new OwnerResource(ownerCurator, null,
            null, null, null, i18n, es, null, null, null, importer, null, null,
            null, importRecordCurator, null, null, null, null, null,
            null, null, null, contentOverrideValidator,
            serviceLevelValidator, null);

        MultipartInput input = mock(MultipartInput.class);
        InputPart part = mock(InputPart.class);
        File archive = mock(File.class);
        List<InputPart> parts = new ArrayList<InputPart>();
        parts.add(part);
        MultivaluedMap<String, String> mm = new MultivaluedMapImpl<String, String>();
        List<String> contDis = new ArrayList<String>();
        contDis.add("form-data; name=\"upload\"; filename=\"test_file.zip\"");
        mm.put("Content-Disposition", contDis);

        when(input.getParts()).thenReturn(parts);
        when(part.getHeaders()).thenReturn(mm);
        when(part.getBody(any(GenericType.class))).thenReturn(archive);
        when(importer.loadExport(eq(owner), any(File.class), any(ConflictOverrides.class)))
            .thenThrow(new ImporterException("Bad import"));

        try {
            thisOwnerResource.importManifest(owner.getKey(), new String [] {}, input);
        }
        catch (IseException ise) {
            // expected, so we catch and go on.
        }
        List<ImportRecord> records = importRecordCurator.findRecords(owner);
View Full Code Here

    public void upstreamConsumers() {
        Principal p = mock(Principal.class);
        OwnerCurator oc = mock(OwnerCurator.class);
        UpstreamConsumer upstream = mock(UpstreamConsumer.class);
        Owner owner = mock(Owner.class);
        OwnerResource ownerres = new OwnerResource(oc, null,
            null, null, null, i18n, null, null, null, null, null, null, null,
            null, null, null, null, null, null, null, null, null, null,
            contentOverrideValidator, serviceLevelValidator, null);

        when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
        when(owner.getUpstreamConsumer()).thenReturn(upstream);

        List<UpstreamConsumer> results = ownerres.getUpstreamConsumers(p, "admin");
        assertNotNull(results);
        assertEquals(1, results.size());
    }
View Full Code Here

TOP

Related Classes of org.candlepin.resource.OwnerResource

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.