@Test public void testStart() throws Exception { radar.start(); Map<String, D3Vector> allEntities = new ConcurrentHashMap<>(); setField(radar, "allEntities", allEntities); allEntities.put("drone-id", D3Vector.ZERO); Assert.assertThat(discoverer.getRemovedHandlers().size(), is(1)); DiscoveryNode node = new DiscoveryNode("drone-id", new DiscoveryNode("root"), DiscoveryPath.config(Type.DRONE, Group.DRONE, "name")); RemovedNode removedNode = new RemovedNode(node); discoverer.getRemovedHandlers().get(0).handle(removedNode); Assert.assertThat(allEntities.values(), not(hasItem(D3Vector.ZERO))); Assert.assertThat(allEntities.size(), is(0)); Radar radarStateBefore = new Radar(radar); removedNode = new RemovedNode(new DiscoveryNode("random node", new DiscoveryNode("root"), DiscoveryPath.config(Type.SERVICE, Group.TACTIC, "some tactic"))); discoverer.getRemovedHandlers().get(0).handle(removedNode); Assert.assertThat(radarStateBefore, is(radar)); }
public void start() { List<NodeEventHandler<RemovedNode>> removedNodeHandlers = new ArrayList<>(); removedNodeHandlers.add((RemovedNode e) -> { DiscoveryNode node = e.getNode(); DiscoveryPath path = node.getPath(); if (path.startsWith(DiscoveryPath.type(Type.DRONE)) && path.isConfigPath()) { String protocolId = node.getId(); this.allEntities.remove(protocolId); } }); this.discoverer.addHandlers(true, Collections.emptyList(), Collections.emptyList(), removedNodeHandlers); architectureEventController.addHandler(SimulationState.INIT, SimulationAction.CONFIG, SimulationState.CONFIG, (fromState, action, toState) -> allEntities.clear()); }
Radar implements Subscriber { public void start() { List<NodeEventHandler<RemovedNode>> removedNodeHandlers = new ArrayList<>(); removedNodeHandlers.add((RemovedNode e) -> { DiscoveryNode node = e.getNode(); DiscoveryPath path = node.getPath(); if (path.startsWith(DiscoveryPath.type(Type.DRONE)) && path.isConfigPath()) { String protocolId = node.getId(); this.allEntities.remove(protocolId); } }); this.discoverer.addHandlers(true, Collections.emptyList(), Collections.emptyList(), removedNodeHandlers); architectureEventController.addHandler(SimulationState.INIT, SimulationAction.CONFIG, SimulationState.CONFIG, (fromState, action, toState) -> allEntities.clear()); } }
Radar implements Subscriber { public void start() { List<NodeEventHandler<RemovedNode>> removedNodeHandlers = new ArrayList<>(); removedNodeHandlers.add((RemovedNode e) -> { DiscoveryNode node = e.getNode(); DiscoveryPath path = node.getPath(); if (path.startsWith(DiscoveryPath.type(Type.DRONE)) && path.isConfigPath()) { String protocolId = node.getId(); this.allEntities.remove(protocolId); } }); this.discoverer.addHandlers(true, Collections.emptyList(), Collections.emptyList(), removedNodeHandlers); architectureEventController.addHandler(SimulationState.INIT, SimulationAction.CONFIG, SimulationState.CONFIG, (fromState, action, toState) -> allEntities.clear()); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); }
Radar implements Subscriber { public void start() { List<NodeEventHandler<RemovedNode>> removedNodeHandlers = new ArrayList<>(); removedNodeHandlers.add((RemovedNode e) -> { DiscoveryNode node = e.getNode(); DiscoveryPath path = node.getPath(); if (path.startsWith(DiscoveryPath.type(Type.DRONE)) && path.isConfigPath()) { String protocolId = node.getId(); this.allEntities.remove(protocolId); } }); this.discoverer.addHandlers(true, Collections.emptyList(), Collections.emptyList(), removedNodeHandlers); architectureEventController.addHandler(SimulationState.INIT, SimulationAction.CONFIG, SimulationState.CONFIG, (fromState, action, toState) -> allEntities.clear()); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); D3Vector getPosition(); void setPosition(D3Vector position); void start(); List<D3Vector> getRadar(); Optional<D3Vector> getNearestTarget(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); @Override boolean equals(Object o); @Override int hashCode(); }
Radar implements Subscriber { public void start() { List<NodeEventHandler<RemovedNode>> removedNodeHandlers = new ArrayList<>(); removedNodeHandlers.add((RemovedNode e) -> { DiscoveryNode node = e.getNode(); DiscoveryPath path = node.getPath(); if (path.startsWith(DiscoveryPath.type(Type.DRONE)) && path.isConfigPath()) { String protocolId = node.getId(); this.allEntities.remove(protocolId); } }); this.discoverer.addHandlers(true, Collections.emptyList(), Collections.emptyList(), removedNodeHandlers); architectureEventController.addHandler(SimulationState.INIT, SimulationAction.CONFIG, SimulationState.CONFIG, (fromState, action, toState) -> allEntities.clear()); } Radar();  Radar(ArchitectureEventController architectureEventController, DroneInit drone, Discoverer discoverer, D3Vector position);  Radar(Radar copy); D3Vector getPosition(); void setPosition(D3Vector position); void start(); List<D3Vector> getRadar(); Optional<D3Vector> getNearestTarget(); @Override void receive(Object msg, MultipartCallbacks multipartCallbacks); @Override boolean equals(Object o); @Override int hashCode(); static final int RADAR_RANGE; }