#BAEL-5880:refactor test cases
This commit is contained in:
parent
f17c551fc4
commit
97895148e3
@ -4,47 +4,26 @@ import org.junit.Assert;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.Map;
|
||||||
|
|
||||||
public class PdfInfoITextUnitTest {
|
public class PdfInfoITextUnitTest {
|
||||||
|
|
||||||
private static final String PDF_FILE = "src/test/resources/input.pdf";
|
private static final String PDF_FILE = "src/test/resources/input.pdf";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenGetNumberOfPage_thenOK() throws IOException {
|
public void givenPdf_whenGetNumberOfPages_thenOK() throws IOException {
|
||||||
// given
|
Assert.assertEquals(4, PdfInfoIText.getNumberOfPages(PDF_FILE));
|
||||||
int expectedNumberOfPage = 4;
|
|
||||||
|
|
||||||
// when
|
|
||||||
int actualNumberOfPage = PdfInfoIText.getNumberOfPage(PDF_FILE);
|
|
||||||
|
|
||||||
// then
|
|
||||||
Assert.assertEquals(expectedNumberOfPage, actualNumberOfPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenIsPasswordRequired_thenOK() throws IOException {
|
public void givenPdf_whenIsPasswordRequired_thenOK() throws IOException {
|
||||||
// given
|
Assert.assertEquals(false, PdfInfoIText.isPasswordRequired(PDF_FILE));
|
||||||
boolean expectedPasswordRequired = false;
|
|
||||||
|
|
||||||
// when
|
|
||||||
boolean actualPasswordRequired = PdfInfoIText.isPasswordRequired(PDF_FILE);
|
|
||||||
|
|
||||||
// then
|
|
||||||
Assert.assertEquals(expectedPasswordRequired, actualPasswordRequired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenGetInfo_thenOK() throws IOException {
|
public void givenPdf_whenGetInfo_thenOK() throws IOException {
|
||||||
// given
|
Map<String, String> info = PdfInfoIText.getInfo(PDF_FILE);
|
||||||
String expectedProducer = "LibreOffice 4.2";
|
Assert.assertEquals("LibreOffice 4.2", info.get("Producer"));
|
||||||
String expectedCreator = "Writer";
|
Assert.assertEquals("Writer", info.get("Creator"));
|
||||||
|
|
||||||
// when
|
|
||||||
HashMap<String, String> info = PdfInfoIText.getInfo(PDF_FILE);
|
|
||||||
|
|
||||||
// then
|
|
||||||
Assert.assertEquals(expectedProducer, info.get("Producer"));
|
|
||||||
Assert.assertEquals(expectedCreator, info.get("Creator"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,40 +11,19 @@ public class PdfInfoPdfBoxUnitTest {
|
|||||||
private static final String PDF_FILE = "src/test/resources/input.pdf";
|
private static final String PDF_FILE = "src/test/resources/input.pdf";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenGetNumberOfPage_thenOK() throws IOException {
|
public void givenPdf_whenGetNumberOfPages_thenOK() throws IOException {
|
||||||
// given
|
Assert.assertEquals(4, PdfInfoPdfBox.getNumberOfPages(PDF_FILE));
|
||||||
int expectedNumberOfPage = 4;
|
|
||||||
|
|
||||||
// when
|
|
||||||
int actualNumberOfPage = PdfInfoPdfBox.getNumberOfPage(PDF_FILE);
|
|
||||||
|
|
||||||
// then
|
|
||||||
Assert.assertEquals(expectedNumberOfPage, actualNumberOfPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenIsPasswordRequired_thenOK() throws IOException {
|
public void givenPdf_whenIsPasswordRequired_thenOK() throws IOException {
|
||||||
// given
|
Assert.assertEquals(false, PdfInfoPdfBox.isPasswordRequired(PDF_FILE));
|
||||||
boolean expectedPasswordRequired = false;
|
|
||||||
|
|
||||||
// when
|
|
||||||
boolean actualPasswordRequired = PdfInfoPdfBox.isPasswordRequired(PDF_FILE);
|
|
||||||
|
|
||||||
// then
|
|
||||||
Assert.assertEquals(expectedPasswordRequired, actualPasswordRequired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenPdf_whenGetInfo_thenOK() throws IOException {
|
public void givenPdf_whenGetInfo_thenOK() throws IOException {
|
||||||
// given
|
|
||||||
String expectedProducer = "LibreOffice 4.2";
|
|
||||||
String expectedCreator = "Writer";
|
|
||||||
|
|
||||||
// when
|
|
||||||
PDDocumentInformation info = PdfInfoPdfBox.getInfo(PDF_FILE);
|
PDDocumentInformation info = PdfInfoPdfBox.getInfo(PDF_FILE);
|
||||||
|
Assert.assertEquals("LibreOffice 4.2", info.getProducer());
|
||||||
// then
|
Assert.assertEquals("Writer", info.getCreator());
|
||||||
Assert.assertEquals(expectedProducer, info.getProducer());
|
|
||||||
Assert.assertEquals(expectedCreator, info.getCreator());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user