dan-s1 commented on code in PR #8691:
URL: https://github.com/apache/nifi/pull/8691#discussion_r1608670513


##########
nifi-extension-bundles/nifi-network-bundle/nifi-network-processors/src/test/java/org/apache/nifi/processors/network/pcap/TestSplitPCAP.java:
##########
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.nifi.processors.network.pcap;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+
+public class TestSplitPCAP {
+
+    private Header hdr;
+    private Packet validPacket;
+    private Packet invalidPacket;
+
+    @BeforeEach
+    public void init() {
+        // Create a header for the test PCAP
+        this.hdr = new Header(
+            new byte[]{(byte) 0xa1, (byte) 0xb2, (byte) 0xc3, (byte) 0xd4},
+            2,
+            4,
+            0,
+            (long) 0,
+            (long) 40,
+            (long) 1 // ETHERNET
+        );
+
+        this.validPacket = new Packet(
+            (long) 1713184965,
+            (long) 1000,
+            (long) 30,
+            (long) 30,
+            new byte[]{
+                0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
+                10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+                20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+            }
+        );
+
+        this.invalidPacket = new Packet(
+            (long) 1713184965,
+            (long) 1000,
+            (long) 10,
+            (long) 10,
+            new byte[]{
+                0,  1,  2,  3,  4,  5,  6,  7,  8,  9,
+                10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
+                20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+            }
+        );
+
+    }
+
+    @Test
+    public void testValidPackets() throws IOException {
+        TestRunner runner = TestRunners.newTestRunner(SplitPCAP.class);
+        runner.setProperty(SplitPCAP.PCAP_MAX_SIZE, "100");
+
+        List<Packet> packets = new ArrayList<>();
+        for (var loop = 0; loop < 3; loop++) {
+            packets.add(this.validPacket);
+        }

Review Comment:
   Intellij says the `throws` is not necessary as an `IOException` is not being 
thrown.
   In addition, it turns out Java already has a method to repeat an object in a 
collection as seen below.
   Please include `import java.util.Collections;`.
   
   ```suggestion
       public void testValidPackets()  {
           TestRunner runner = TestRunners.newTestRunner(SplitPCAP.class);
           runner.setProperty(SplitPCAP.PCAP_MAX_SIZE, "100");
   
            List<Packet> packets = Collections.nCopies(3, this.validPacket);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to