### Question:
Network { List<MessageArrival> createMessageArrivals( Message<? extends TN> m, int sendTime, TN fromNode, List<? extends Node> dests, int randomSeed, int delaysBetweenMessage) { ArrayList<MessageArrival> da = new ArrayList<>(dests.size()); for (Node n : dests) { MessageArrival ma = createMessageArrival(m, fromNode, n, sendTime, randomSeed); sendTime += delaysBetweenMessage + (delaysBetweenMessage > 0 ? 1 : 0); if (ma != null) { da.add(ma); } } Collections.sort(da); return da; }  static BitSet chooseBadNodes(Random rd, int nodeCount, int nodesDown); BitSet getDeadNodes(); TN getNodeById(int id); TN getFirstLiveNode(); void printSpeedDistribution(int segmentCt); @SuppressWarnings("UnusedReturnValue") Network<TN> setMsgDiscardTime(int l); void run(int seconds); void runH(int hours); boolean runMs(int ms); void sendAll(Message<? extends TN> m, int sendTime, TN fromNode); void sendAll(Message<? extends TN> m, TN fromNode); void send(Message<? extends TN> m, TN fromNode, List<TN> dests); void send(Message<? extends TN> m, TN fromNode, TN toNode); void send(Message<? extends TN> mc, int sendTime, TN fromNode, TN toNode); void sendArriveAt(Message<? extends TN> mc, int arriveAt, TN fromNode, TN toNode); boolean hasMessage(); void send(Message<? extends TN> m, int sendTime, TN fromNode, List<? extends Node> dests); void send(
      Message<? extends TN> m,
      int sendTime,
      TN fromNode,
      List<? extends Node> dests,
      int delaysBetweenMessage); static int getPseudoRandom(int nodeId, int randomSeed); void registerTask(final Runnable task, int startAt, TN fromNode); void registerPeriodicTask(final Runnable task, int startAt, int period, TN fromNode); void registerPeriodicTask(
      final Runnable task, int startAt, int period, TN fromNode, Condition c); void registerConditionalTask(
      final Runnable task,
      int startAt,
      int duration,
      TN fromNode,
      Condition startIf,
      Condition repeatIf); void addNode(TN node); List<TN> liveNodes(); Network<TN> setNetworkLatency(int[] distribProp, int[] distribVal); Network<TN> setNetworkLatency(NetworkLatency networkLatency); void printNetworkLatency(); void partition(float part); void endPartition(); final MessageStorage msgs; final List<ConditionalTask<TN>> conditionalTasks; final List<TN> allNodes; final Random rd; public NetworkLatency networkLatency; public int time; }### Answer:
@Test public void testMsgArrival() { List<Network.MessageArrival> mas = network.createMessageArrivals(m, 1, n0, List.of(n1, n2, n3), 1, 10); Assert.assertEquals(3, mas.size()); Collections.sort(mas); Assert.assertEquals(2, mas.get(0).arrival); Assert.assertEquals(13, mas.get(1).arrival); Assert.assertEquals(24, mas.get(2).arrival); Envelope.MultipleDestWithDelayEnvelope<Node> e = new Envelope.MultipleDestWithDelayEnvelope<>(m, n0, mas, 1); Assert.assertEquals(2, e.nextArrivalTime(network)); e.markRead(); Assert.assertEquals(13, e.nextArrivalTime(network)); e.markRead(); Assert.assertEquals(24, e.nextArrivalTime(network)); Assert.assertTrue(e.hasNextReader()); e.markRead(); Assert.assertFalse(e.hasNextReader()); }