Manager { public boolean addNode(final Node newNode){ synchronized (mDiscoverNode) { String newTag = newNode.getTag(); Node n = this.getNodeWithTag(newTag); if(n!=null){ n.upDateAdvertising(newNode.getAdvertiseInfo()); n.isAlive(newNode.getLastRssi()); return false; }else { newNode.addNodeStateListener(mDebugNodeStatus); mDiscoverNode.add(newNode); } } notifyNewNodeDiscovered(newNode); return true; } private  Manager(); static List<AdvertiseFilter> buildDefaultAdvertiseList(); static synchronized Manager getSharedInstance(); @RequiresPermission(allOf = { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN}) boolean startDiscovery(); @RequiresPermission(allOf = { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN}) boolean startDiscovery(int timeoutMs); @RequiresPermission(allOf = { Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.BLUETOOTH, Manifest.permission.BLUETOOTH_ADMIN}) boolean startDiscovery(int timeoutMs,List<AdvertiseFilter> filters); boolean hasConnectedNodes(); boolean isMPhy2Supported(); void addVirtualNode(); boolean addNode(final Node newNode); boolean stopDiscovery(); boolean isDiscovering(); void resetDiscovery(); void addListener(ManagerListener listener); void removeListener(ManagerListener listener); @Nullable Node getNodeWithTag(@NonNull String tag); @Nullable Node getNodeWithName(String name); List<Node> getNodes(); static void addFeatureToNode(byte deviceId,SparseArray<Class<? extends Feature>> features); static @NonNull SparseArray<Class<? extends Feature>> getNodeFeatures(byte deviceId);  }
@Test public void addNodeTest() { Node node = null; try { node = new NodeEmulator(); } catch (InvalidBleAdvertiseFormat invalidBleAdvertiseFormat) { invalidBleAdvertiseFormat.printStackTrace(); Assert.fail("Impossible build a node emulator: " + invalidBleAdvertiseFormat); } mManager.addNode(node); Assert.assertEquals(1, mManager.getNodes().size()); Assert.assertEquals(node, mManager.getNodes().get(0)); }