@@ -0,0 +1,2537 @@
+package org.verapdf.model.impl.pb.operator.base;%0A%0Aimport org.apache.pdfbox.cos.COSObject;%0Aimport org.apache.pdfbox.cos.COSObjectKey;%0Aimport org.apache.pdfbox.cos.COSStream;%0Aimport org.apache.pdfbox.pdfparser.PDFStreamParser;%0Aimport org.apache.pdfbox.pdmodel.PDResources;%0Aimport org.junit.Assert;%0Aimport org.verapdf.model.baselayer.Object;%0Aimport org.verapdf.model.coslayer.CosDict;%0Aimport org.verapdf.model.factory.operator.OperatorFactory;%0Aimport org.verapdf.model.impl.BaseTest;%0Aimport org.verapdf.model.operator.Operator;%0A%0Aimport java.io.IOException;%0Aimport java.net.URISyntaxException;%0Aimport java.util.List;%0A%0A/**%0A * @author Evgeniy Muravitskiy%0A */%0Apublic abstract class PBOperatorTest extends BaseTest %7B%0A%0A%09public static final String FILE_RELATIVE_PATH = %22operator/Operators.pdf%22;%0A%0A%09private static final COSObjectKey KEY = new COSObjectKey(15, 0);%0A%0A%09protected static void setUpOperatorsList(String type, String id) throws IOException, URISyntaxException %7B%0A%09%09expectedType = TYPES.contains(type) ? type : null;%0A%09%09expectedID = id;%0A%09%09setUp(FILE_RELATIVE_PATH);%0A%0A%09%09COSObject objectFromPool = document.getDocument().getObjectFromPool(KEY);%0A%09%09COSStream stream = (COSStream) objectFromPool.getObject();%0A%09%09PDResources resources = document.getPage(0).getResources();%0A%0A%09%09PDFStreamParser parser = new PDFStreamParser(stream, true);%0A%09%09parser.parse();%0A%0A%09%09List%3COperator%3E operators = OperatorFactory.operatorsFromTokens(parser.getTokens(), resources);%0A%09%09actual = getActual(operators, expectedType);%0A%0A%09%09operators.clear();%0A%09%7D%0A%0A%09private static Object getActual(List%3COperator%3E operators, String type) %7B%0A%09%09for (Operator operator : operators) %7B%0A%09%09%09if (type.equals(operator.getType())) %7B%0A%09%09%09%09return operator;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return null;%0A%09%7D%0A%0A%09protected void testLinksToReals(String link, int count, String type) %7B%0A%09%09List%3C? extends Object%3E linkedObjects = actual.getLinkedObjects(link);%0A%0A%09%09Assert.assertEquals(count, linkedObjects.size());%0A%0A%09%09for (Object object : linkedObjects) %7B%0A%09%09%09Assert.assertEquals(type, object.getType());%0A%09%09%7D%0A%0A%09%7D%0A%0A%09protected static void testLinkToDictionary(String link, String type, Number expectedResult) %7B%0A%09%09Object object = getObject(link, 1, type);%0A%09%09Assert.assertEquals(expectedResult, ((CosDict) object).getsize());%0A%09%7D%0A%0A%09protected static Object getObject(String link, int count, String type) %7B%0A%09%09List%3C? extends Object%3E linkedObjects = actual.getLinkedObjects(link);%0A%0A%09%09Assert.assertEquals(count, linkedObjects.size());%0A%0A%09%09Object object = linkedObjects.get(0);%0A%0A%09%09Assert.assertEquals(type, object.getType());%0A%09%09return object;%0A%09%7D%0A%0A%7D%0A

Add base unit test for operators