Package org.candlepin.sync

Examples of org.candlepin.sync.Importer


    }

    @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);
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);
        }
View Full Code Here

TOP

Related Classes of org.candlepin.sync.Importer

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.