// Path: api/src/test/java/xyz/docbleach/api/BleachTestBase.java
// public static void assertThreatsFound(BleachSession session, int n) {
//   verify(session, times(n)).recordThreat(any(Threat.class));
// }
// 
// Path: api/src/main/java/xyz/docbleach/api/BleachSession.java
// public class BleachSession implements Serializable {
// 
//   private static final Logger LOGGER = LoggerFactory.getLogger(BleachSession.class);
//   private static final int MAX_ONGOING_TASKS = 10;
//   private final transient Bleach bleach;
//   private final Collection<Threat> threats = new ArrayList<>();
//   /**
//    * Counts ongoing tasks, to prevent fork bombs when handling zip archives for instance)
//    */
//   private int ongoingTasks = 0;
// 
//   public BleachSession(Bleach bleach) {
//     this.bleach = bleach;
//   }
// 
//   /**
//    * The BleachSession is able to record threats encountered by the bleach.
//    *
//    * @param threat The removed threat object, containing the threat type and more information
//    */
//   public void recordThreat(Threat threat) {
//     if (threat == null) {
//       return;
//     }
//     LOGGER.trace("Threat recorded: " + threat);
//     threats.add(threat);
//   }
// 
//   public Collection<Threat> getThreats() {
//     return threats;
//   }
// 
//   public int threatCount() {
//     return threats.size();
//   }
// 
//   /**
//    * @return The bleach used in this session
//    */
//   public Bleach getBleach() {
//     return bleach;
//   }
// 
//   public void sanitize(InputStream is, OutputStream os) throws BleachException {
//     try {
//       if (ongoingTasks++ >= MAX_ONGOING_TASKS) {
//         throw new RecursionBleachException(ongoingTasks);
//       }
//       if (!bleach.handlesMagic(is)) {
//         return;
//       }
//       bleach.sanitize(is, os, this);
//     } finally {
//       ongoingTasks--;
//     }
//   }
// }


import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static xyz.docbleach.api.BleachTestBase.assertThreatsFound;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.interactive.action.PDActionJavaScript;
import org.apache.pdfbox.pdmodel.interactive.action.PDDocumentCatalogAdditionalActions;
import org.apache.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions;
import org.apache.pdfbox.pdmodel.interactive.action.PDPageAdditionalActions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import xyz.docbleach.api.BleachSession;

    instance.sanitizePageActions(actions);
    assertThreatsFound(session, 0);
  }

  @Test
  void sanitizeAdditionalActions() {
    PDDocumentCatalogAdditionalActions documentCatalogAdditionalActions =
        new PDDocumentCatalogAdditionalActions();
    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    documentCatalogAdditionalActions.setDP(new PDActionJavaScript());
    documentCatalogAdditionalActions.setDS(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWC(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWP(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWS(new PDActionJavaScript());

    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    assertThreatsFound(session, 5);
    reset(session);

    assertNull(documentCatalogAdditionalActions.getDP());
    assertNull(documentCatalogAdditionalActions.getDS());
    assertNull(documentCatalogAdditionalActions.getWC());
    assertNull(documentCatalogAdditionalActions.getWP());
    assertNull(documentCatalogAdditionalActions.getWS());

    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    assertThreatsFound(session, 0);
  }

// Path: api/src/test/java/xyz/docbleach/api/BleachTestBase.java
// public static void assertThreatsFound(BleachSession session, int n) {
//   verify(session, times(n)).recordThreat(any(Threat.class));
// }
// 
// Path: api/src/main/java/xyz/docbleach/api/BleachSession.java
// public class BleachSession implements Serializable {
// 
//   private static final Logger LOGGER = LoggerFactory.getLogger(BleachSession.class);
//   private static final int MAX_ONGOING_TASKS = 10;
//   private final transient Bleach bleach;
//   private final Collection<Threat> threats = new ArrayList<>();
//   /**
//    * Counts ongoing tasks, to prevent fork bombs when handling zip archives for instance)
//    */
//   private int ongoingTasks = 0;
// 
//   public BleachSession(Bleach bleach) {
//     this.bleach = bleach;
//   }
// 
//   /**
//    * The BleachSession is able to record threats encountered by the bleach.
//    *
//    * @param threat The removed threat object, containing the threat type and more information
//    */
//   public void recordThreat(Threat threat) {
//     if (threat == null) {
//       return;
//     }
//     LOGGER.trace("Threat recorded: " + threat);
//     threats.add(threat);
//   }
// 
//   public Collection<Threat> getThreats() {
//     return threats;
//   }
// 
//   public int threatCount() {
//     return threats.size();
//   }
// 
//   /**
//    * @return The bleach used in this session
//    */
//   public Bleach getBleach() {
//     return bleach;
//   }
// 
//   public void sanitize(InputStream is, OutputStream os) throws BleachException {
//     try {
//       if (ongoingTasks++ >= MAX_ONGOING_TASKS) {
//         throw new RecursionBleachException(ongoingTasks);
//       }
//       if (!bleach.handlesMagic(is)) {
//         return;
//       }
//       bleach.sanitize(is, os, this);
//     } finally {
//       ongoingTasks--;
//     }
//   }
// }


// Path: module/module-pdf/src/test/java/xyz/docbleach/module/pdf/PDDocumentCatalogBleachTest.java
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static xyz.docbleach.api.BleachTestBase.assertThreatsFound;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocumentCatalog;
import org.apache.pdfbox.pdmodel.interactive.action.PDActionJavaScript;
import org.apache.pdfbox.pdmodel.interactive.action.PDDocumentCatalogAdditionalActions;
import org.apache.pdfbox.pdmodel.interactive.action.PDFormFieldAdditionalActions;
import org.apache.pdfbox.pdmodel.interactive.action.PDPageAdditionalActions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import xyz.docbleach.api.BleachSession;


    instance.sanitizePageActions(actions);
    assertThreatsFound(session, 0);
  }

  @Test
  void sanitizeAdditionalActions() {
    PDDocumentCatalogAdditionalActions documentCatalogAdditionalActions =
        new PDDocumentCatalogAdditionalActions();
    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    documentCatalogAdditionalActions.setDP(new PDActionJavaScript());
    documentCatalogAdditionalActions.setDS(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWC(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWP(new PDActionJavaScript());
    documentCatalogAdditionalActions.setWS(new PDActionJavaScript());

    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    assertThreatsFound(session, 5);
    reset(session);

    assertNull(documentCatalogAdditionalActions.getDP());
    assertNull(documentCatalogAdditionalActions.getDS());
    assertNull(documentCatalogAdditionalActions.getWC());
    assertNull(documentCatalogAdditionalActions.getWP());
    assertNull(documentCatalogAdditionalActions.getWS());

    instance.sanitizeDocumentActions(documentCatalogAdditionalActions);
    assertThreatsFound(session, 0);
  }

  @Test