/** * Configures source node * * <p>Has working layer1, used to send packets */ private DEECoContainer setupSourceNode(int id) { DEECoContainer node = Mockito.mock(DEECoContainer.class); // Configure id for mocked container Mockito.when(node.getId()).thenReturn(id); // Configure runtime Mockito.when(node.getRuntimeFramework()).thenReturn(runtime); // Configure Network for mocked container Layer1 layer1 = new Layer1((byte) id, DefaultDataIDSource.getInstance(), scheduler); Network network = Mockito.mock(Network.class); Mockito.when(network.getL1()).thenReturn(layer1); Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network); return node; }
/** * Configures destination node * * <p>Has mocked layer1, used to confirm packet reception */ private DEECoContainer setupDestinationNode(int id) { DEECoContainer node = Mockito.mock(DEECoContainer.class); // Configure id for mocked container Mockito.when(node.getId()).thenReturn(id); // Configure runtime Mockito.when(node.getRuntimeFramework()).thenReturn(runtime); // Configure Network for mocked container Layer1 layer1 = Mockito.spy(new Layer1((byte) id, DefaultDataIDSource.getInstance(), scheduler)); Mockito.doNothing().when(layer1).processL0Packet(Mockito.any(), Mockito.any(), Mockito.any()); Network network = Mockito.mock(Network.class); Mockito.when(network.getL1()).thenReturn(layer1); Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network); return node; }