| 1 |
/* |
| 2 |
* Created on 27/gen/2014 |
| 3 |
* Copyright 2014 by Andrea Vacondio ([email protected]). |
| 4 |
* |
| 5 |
* This file is part of the Sejda source code |
| 6 |
* |
| 7 |
* This program is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Affero General Public License as |
| 9 |
* published by the Free Software Foundation, either version 3 of the |
| 10 |
* License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Affero General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Affero General Public License |
| 18 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
package org.sejda.conversion; |
| 21 |
|
| 22 |
import static org.junit.Assert.assertEquals; |
| 23 |
import static org.junit.Assert.assertFalse; |
| 24 |
import static org.junit.Assert.assertTrue; |
| 25 |
import static org.mockito.Mockito.mock; |
| 26 |
import static org.mockito.Mockito.when; |
| 27 |
|
| 28 |
import java.io.File; |
| 29 |
import java.util.ArrayList; |
| 30 |
import java.util.List; |
| 31 |
|
| 32 |
import org.junit.Test; |
| 33 |
import org.sejda.model.input.PdfFileSource; |
| 34 |
import org.sejda.model.input.PdfMergeInput; |
| 35 |
|
| 36 |
/** |
| 37 |
* @author Andrea Vacondio |
| 38 |
* |
| 39 |
*/ |
| 40 |
public class MultiplePdfMergeInputAdapterTest { |
| 41 |
|
| 42 |
@Test |
| 43 |
public void testPositive(){ |
| 44 |
File file = mock(File.class); |
| 45 |
when(file.isFile()).thenReturn(true); |
| 46 |
when(file.getName()).thenReturn("test.pdf"); |
| 47 |
List<PdfFileSource> inputList = new ArrayList<PdfFileSource>(); |
| 48 |
inputList.add(PdfFileSource.newInstanceNoPassword(file)); |
| 49 |
inputList.add(PdfFileSource.newInstanceNoPassword(file)); |
| 50 |
List<PdfMergeInput> result = new MultiplePdfMergeInputAdapter(inputList, |
| 51 |
new MultiplePageRangeSetAdapter("3-5").ranges()).getPdfMergeInputs(); |
| 52 |
assertEquals(2, result.size()); |
| 53 |
assertFalse(result.get(0).isAllPages()); |
| 54 |
assertTrue(result.get(1).isAllPages()); |
| 55 |
} |
| 56 |
} |