Skip to content

Package: NewNetworkAdapterAction$VisitorForHardwareEdge

NewNetworkAdapterAction$VisitorForHardwareEdge

nameinstructionbranchcomplexitylinemethod
NewNetworkAdapterAction.VisitorForHardwareEdge(NewNetworkAdapterAction, Node)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
adapter(NetworkAdapter)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
configRouter(ConfigRouter)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
hardwareEdge(HardwareEdge)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
host(Host)
M: 0 C: 13
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
internet(Internet)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
networkCable(NetworkCable)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
router(Router)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
sWitch(Switch)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
slot(Slot)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: package networkconfigurator.actions;
2:
3: import java.awt.Point;
4:
5: import model.assignment.VariableAssignment;
6: import networkconfigurator.ConfigurationGraph;
7: import networkconfigurator.item.ConfigRouter;
8: import networkconfigurator.item.Device;
9: import networkconfigurator.item.HardwareEdge;
10: import networkconfigurator.item.Host;
11: import networkconfigurator.item.Internet;
12: import networkconfigurator.item.ItemVisitor;
13: import networkconfigurator.item.NetworkAdapter;
14: import networkconfigurator.item.NetworkCable;
15: import networkconfigurator.item.Node;
16: import networkconfigurator.item.Router;
17: import networkconfigurator.item.Slot;
18: import networkconfigurator.item.Switch;
19:
20: /**
21: * Action for adding a new Node.
22: *
23: * @author Erik Arand
24: *
25: */
26: public class NewNetworkAdapterAction extends AbstractNewAction {
27:
28:         /**
29:          * the configurationgraph.
30:          */
31:         private final ConfigurationGraph graph;
32:
33:         /**
34:          * Action for a new NetworkAdapter.
35:          *
36:          * @param name
37:          * the name of the node.
38:          * @param graph
39:          * the graph.
40:          */
41:         public NewNetworkAdapterAction(final String name, final ConfigurationGraph graph) {
42:                 super(name, graph);
43:                 this.graph = graph;
44:         }
45:
46:         @Override
47:         protected Node createNode(final Point p) {
48:                 final Device owner = (Device) graph.getSelected().get(0);
49:                 final Node newAdapter =
50:                                 new NetworkAdapter(p, owner, new VariableAssignment(null, null, "eth0", null),
51:                                                 new VariableAssignment(null, null, "", null));
52:
53:                 graph.getSelected().get(0).accept(new VisitorForHardwareEdge(newAdapter));
54:                 return newAdapter;
55:         }
56:
57:         /**
58:          * Visitor for adding hardwareEdges between the new Adapter and the device.
59:          *
60:          * @author admin
61:          *
62:          */
63:         private final class VisitorForHardwareEdge implements ItemVisitor {
64:                 /**
65:                  * the new Adapter.
66:                  */
67:                 private final Node newAdapter;
68:
69:                 /**
70:                  * the constructor.
71:                  *
72:                  * @param newAdapter
73:                  * the new adapter.
74:                  */
75:                 private VisitorForHardwareEdge(final Node newAdapter) {
76:                         this.newAdapter = newAdapter;
77:                 }
78:
79:                 @Override
80:                 public void sWitch(final Switch sWitch) {
81:                 }
82:
83:                 @Override
84:                 public void router(final Router router) {
85:                         graph.getItems().add(new HardwareEdge(router, newAdapter));
86:                 }
87:
88:                 @Override
89:                 public void networkCable(final NetworkCable edge) {
90:                 }
91:
92:                 @Override
93:                 public void internet(final Internet internet) {
94:                 }
95:
96:                 @Override
97:                 public void host(final Host host) {
98:                         graph.getItems().add(new HardwareEdge(host, newAdapter));
99:                 }
100:
101:                 @Override
102:                 public void hardwareEdge(final HardwareEdge edge) {
103:                 }
104:
105:                 @Override
106:                 public void configRouter(final ConfigRouter router) {
107:                         graph.getItems().add(new HardwareEdge(router, newAdapter));
108:                 }
109:
110:                 @Override
111:                 public void adapter(final NetworkAdapter adapter) {
112:                 }
113:
114:                 @Override
115:                 public void slot(final Slot slot) {
116:                 }
117:         }
118:
119: }