@Test public void Null_ensureADBServiceStarted() { Mockito.when(fileManager.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(getADBAttribute()).thenReturn(adbPath); PowerMockito.mockStatic(AndroidDebugBridge.class); PowerMockito.when(AndroidDebugBridge.getBridge()).thenReturn(null); AndroidDebugBridge adb = adbService.ensureADBServiceStarted(); assertTrue(adb == null); }
@Override public AndroidDebugBridge ensureADBServiceStarted() { AndroidDebugBridge adb = null; adb = AndroidDebugBridge.getBridge(); if (adb != null && adb.isConnected()) { return adb; } String adbPath = getAdbPath(true); if (adbPath != null && adbPath.length() > 3) { adb = initCreateBridge(adbPath); if (adb != null) { int attempt = 1; while (attempt-- > 0 && !checkAdb(adb)) { adb = AndroidDebugBridge.createBridge(adbPath, true); } if (adb == null || !adb.hasInitialDeviceList()) { LOGGER.error("ADB bridge not working or failed to connect."); adb = null; } } else { LOGGER.info("Failed to create ADB Bridge, unable to connect."); } } else { LOGGER.info("No ADB path found, failed to create ADB Bridge."); } return adb; }
AdbServiceImpl implements IAdbService { @Override public AndroidDebugBridge ensureADBServiceStarted() { AndroidDebugBridge adb = null; adb = AndroidDebugBridge.getBridge(); if (adb != null && adb.isConnected()) { return adb; } String adbPath = getAdbPath(true); if (adbPath != null && adbPath.length() > 3) { adb = initCreateBridge(adbPath); if (adb != null) { int attempt = 1; while (attempt-- > 0 && !checkAdb(adb)) { adb = AndroidDebugBridge.createBridge(adbPath, true); } if (adb == null || !adb.hasInitialDeviceList()) { LOGGER.error("ADB bridge not working or failed to connect."); adb = null; } } else { LOGGER.info("Failed to create ADB Bridge, unable to connect."); } } else { LOGGER.info("No ADB path found, failed to create ADB Bridge."); } return adb; } }
AdbServiceImpl implements IAdbService { @Override public AndroidDebugBridge ensureADBServiceStarted() { AndroidDebugBridge adb = null; adb = AndroidDebugBridge.getBridge(); if (adb != null && adb.isConnected()) { return adb; } String adbPath = getAdbPath(true); if (adbPath != null && adbPath.length() > 3) { adb = initCreateBridge(adbPath); if (adb != null) { int attempt = 1; while (attempt-- > 0 && !checkAdb(adb)) { adb = AndroidDebugBridge.createBridge(adbPath, true); } if (adb == null || !adb.hasInitialDeviceList()) { LOGGER.error("ADB bridge not working or failed to connect."); adb = null; } } else { LOGGER.info("Failed to create ADB Bridge, unable to connect."); } } else { LOGGER.info("No ADB path found, failed to create ADB Bridge."); } return adb; }  }
AdbServiceImpl implements IAdbService { @Override public AndroidDebugBridge ensureADBServiceStarted() { AndroidDebugBridge adb = null; adb = AndroidDebugBridge.getBridge(); if (adb != null && adb.isConnected()) { return adb; } String adbPath = getAdbPath(true); if (adbPath != null && adbPath.length() > 3) { adb = initCreateBridge(adbPath); if (adb != null) { int attempt = 1; while (attempt-- > 0 && !checkAdb(adb)) { adb = AndroidDebugBridge.createBridge(adbPath, true); } if (adb == null || !adb.hasInitialDeviceList()) { LOGGER.error("ADB bridge not working or failed to connect."); adb = null; } } else { LOGGER.info("Failed to create ADB Bridge, unable to connect."); } } else { LOGGER.info("No ADB path found, failed to create ADB Bridge."); } return adb; }  @Autowired void setAndroid(IAndroid android); @Autowired void setExternalProcessRunner(IExternalProcessRunner runner); @Autowired void setFileExtactor(IReadWriteFileExtractor extractor); @Autowired void setFileManager(IFileManager fileManager); @Autowired void setAROConfigFile(Settings configFile); @Override boolean hasADBpath(); @Override String getAdbPath(); @Override String getAdbPath(boolean unfiltered); @Override boolean isAdbFileExist(); @Override AndroidDebugBridge initCreateBridge(String adbPath); @Override AndroidDebugBridge ensureADBServiceStarted(); @Override IDevice[] getConnectedDevices(); @Override FileEntry locate(IDevice device, FileEntry rootPath, String path); boolean pullFile(SyncService service, String remotePath, String file, String localFolder); @Override boolean installPayloadFile(IAroDevice aroDevice, String tempFolder, String payloadFileName, String remotepath); @Override boolean installPayloadFile(IDevice device, String tempFolder, String payloadFileName, String remotepath); @Override String[] getApplicationList(String id); }
AdbServiceImpl implements IAdbService { @Override public AndroidDebugBridge ensureADBServiceStarted() { AndroidDebugBridge adb = null; adb = AndroidDebugBridge.getBridge(); if (adb != null && adb.isConnected()) { return adb; } String adbPath = getAdbPath(true); if (adbPath != null && adbPath.length() > 3) { adb = initCreateBridge(adbPath); if (adb != null) { int attempt = 1; while (attempt-- > 0 && !checkAdb(adb)) { adb = AndroidDebugBridge.createBridge(adbPath, true); } if (adb == null || !adb.hasInitialDeviceList()) { LOGGER.error("ADB bridge not working or failed to connect."); adb = null; } } else { LOGGER.info("Failed to create ADB Bridge, unable to connect."); } } else { LOGGER.info("No ADB path found, failed to create ADB Bridge."); } return adb; }  @Autowired void setAndroid(IAndroid android); @Autowired void setExternalProcessRunner(IExternalProcessRunner runner); @Autowired void setFileExtactor(IReadWriteFileExtractor extractor); @Autowired void setFileManager(IFileManager fileManager); @Autowired void setAROConfigFile(Settings configFile); @Override boolean hasADBpath(); @Override String getAdbPath(); @Override String getAdbPath(boolean unfiltered); @Override boolean isAdbFileExist(); @Override AndroidDebugBridge initCreateBridge(String adbPath); @Override AndroidDebugBridge ensureADBServiceStarted(); @Override IDevice[] getConnectedDevices(); @Override FileEntry locate(IDevice device, FileEntry rootPath, String path); boolean pullFile(SyncService service, String remotePath, String file, String localFolder); @Override boolean installPayloadFile(IAroDevice aroDevice, String tempFolder, String payloadFileName, String remotepath); @Override boolean installPayloadFile(IDevice device, String tempFolder, String payloadFileName, String remotepath); @Override String[] getApplicationList(String id);  }