@Ignore @Test public void startCollectorTest(){ Hashtable<String, Object> extranalParams = new Hashtable<String, Object>(); Mockito.when(fileManager.directoryExistAndNotEmpty(Mockito.anyString())).thenReturn(true); StatusResult sResult= null; sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "testDeice", extranalParams, null); assertEquals(402, sResult.getError().getCode()); Mockito.when(fileManager.directoryExistAndNotEmpty(Mockito.anyString())).thenReturn(false); Mockito.doNothing().when(fileManager).mkDir(Mockito.anyString()); Mockito.when(fileManager.directoryExist(Mockito.anyString())).thenReturn(false); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "testDeice", extranalParams, null); assertEquals(406, sResult.getError().getCode()); Mockito.when(fileManager.directoryExist(Mockito.anyString())).thenReturn(true); IDevice aDevice1 = Mockito.mock(IDevice.class); Mockito.when(aDevice1.getSerialNumber()).thenReturn("device1"); IDevice[] devices = {aDevice1}; IDevice[] returnDevices = {}; try { Mockito.when(adbService.getConnectedDevices()).thenReturn(returnDevices); } catch (Exception exp) { exp.printStackTrace(); } sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "testDeice", extranalParams, null); assertEquals(403, sResult.getError().getCode()); try { Mockito.when(adbService.getConnectedDevices()).thenReturn(devices); } catch (Exception exp) { exp.printStackTrace(); } sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "testDeice", extranalParams, null); assertEquals(404, sResult.getError().getCode()); Mockito.when(android.removeEmulatorData(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(true); Mockito.when(android.makeDirectory(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(true); String[] str1 = {}; Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(str1); Mockito.when(fileManager.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(android.runApkInDevice(Mockito.any(IDevice.class),Mockito.anyString())).thenReturn(false); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "device1", extranalParams, null); assertEquals(405, sResult.getError().getCode()); Mockito.when(fileManager.fileExist(Mockito.anyString())).thenReturn(false); Mockito.when(extractor.extractFiles(Mockito.anyString(), Mockito.anyString(), Mockito.any(ClassLoader.class))).thenReturn(false); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "device1", extranalParams, null); assertEquals(401, sResult.getError().getCode()); Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon); Mockito.when(fileManager.fileExist(Mockito.anyString())).thenReturn(true); Mockito.when(android.runApkInDevice(Mockito.any(IDevice.class),Mockito.anyString())).thenReturn(true); Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon).thenReturn(vpnActive); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, false, "device1", extranalParams, null); assertTrue(sResult.isSuccess()); Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(vpnActive).thenReturn(noVpnCon); nonRootedAndroidCollector.stopRunning(); Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon).thenReturn(vpnActive); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.NONE, null); assertTrue(sResult.isSuccess()); nonRootedAndroidCollector.stopRunning(); try { Mockito.doNothing().when(videoCapture).init(Mockito.any(IDevice.class), Mockito.anyString()); Mockito.doNothing().when(videoCapture).addSubscriber(Mockito.any(IVideoImageSubscriber.class)); Mockito.doNothing().when(threadExecutor).execute(Mockito.any(IVideoCapture.class)); } catch (IOException e) { e.printStackTrace(); } Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon).thenReturn(vpnActive); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.LREZ, false, "device1", extranalParams, null); assertTrue(sResult.isSuccess()); nonRootedAndroidCollector.stopRunning(); try { Mockito.when(adbService.getConnectedDevices()).thenThrow(new Exception("AndroidDebugBridge failed to start")); } catch (Exception exp) { exp.printStackTrace(); } Mockito.when(android.getShellReturn(Mockito.any(IDevice.class), Mockito.anyString())).thenReturn(noVpnCon).thenReturn(vpnActive); sResult = nonRootedAndroidCollector.startCollector(true, "test", VideoOption.LREZ, false, "device1", extranalParams, null); assertEquals(400, sResult.getError().getCode()); }
@Override public StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated, String password) { return this.startCollector(isCommandLine, tracepath, videoOption_deprecated, false, null, null, password); }
NorootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated, String password) { return this.startCollector(isCommandLine, tracepath, videoOption_deprecated, false, null, null, password); } }
NorootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated, String password) { return this.startCollector(isCommandLine, tracepath, videoOption_deprecated, false, null, null, password); }  }
NorootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated, String password) { return this.startCollector(isCommandLine, tracepath, videoOption_deprecated, false, null, null, password); }  @Autowired void setMetaDataHelper(IMetaDataHelper metaDataHelper); @Autowired void setAndroid(IAndroid android); @Autowired void setExternalProcessRunner(IExternalProcessRunner runner); @Autowired void setFileManager(IFileManager filemanager); void setDevice(IDevice aDevice); @Autowired void setAdbService(IAdbService adbservice); @Autowired void setVideoCapture(IVideoCapture videocapture); @Autowired void setThreadExecutor(IThreadExecutor thread); @Autowired void setFileExtactor(IReadWriteFileExtractor extractor); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus subscriber); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override void receiveImage(BufferedImage videoimage); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); void stopRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated,
			String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace,
			VideoOption videoOption_deprecated, boolean isLiveViewVideo, String deviceId,
			Hashtable<String, Object> extraParams, String password); void cleanARO(); @Override boolean isTrafficCaptureRunning(int milliSeconds); boolean isVpnActivated(); @Override StatusResult stopCollector(); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled(); }
NorootedAndroidCollectorImpl implements IDataCollector, IVideoImageSubscriber { @Override public StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated, String password) { return this.startCollector(isCommandLine, tracepath, videoOption_deprecated, false, null, null, password); }  @Autowired void setMetaDataHelper(IMetaDataHelper metaDataHelper); @Autowired void setAndroid(IAndroid android); @Autowired void setExternalProcessRunner(IExternalProcessRunner runner); @Autowired void setFileManager(IFileManager filemanager); void setDevice(IDevice aDevice); @Autowired void setAdbService(IAdbService adbservice); @Autowired void setVideoCapture(IVideoCapture videocapture); @Autowired void setThreadExecutor(IThreadExecutor thread); @Autowired void setFileExtactor(IReadWriteFileExtractor extractor); @Override String getName(); @Override void addDeviceStatusSubscriber(IDeviceStatus subscriber); @Override void addVideoImageSubscriber(IVideoImageSubscriber subscriber); @Override void receiveImage(BufferedImage videoimage); @Override int getMajorVersion(); @Override String getMinorVersion(); @Override DataCollectorType getType(); @Override boolean isRunning(); void stopRunning(); @Override String[] getLog(); @Override StatusResult startCollector(boolean isCommandLine, String tracepath, VideoOption videoOption_deprecated,
			String password); @Override StatusResult startCollector(boolean isCommandLine, String folderToSaveTrace,
			VideoOption videoOption_deprecated, boolean isLiveViewVideo, String deviceId,
			Hashtable<String, Object> extraParams, String password); void cleanARO(); @Override boolean isTrafficCaptureRunning(int milliSeconds); boolean isVpnActivated(); @Override StatusResult stopCollector(); @Override void timeOutShutdown(); @Override void haltCollectorInDevice(); @Override String getPassword(); @Override boolean setPassword(String requestPassword); @Override String[] getDeviceSerialNumber(StatusResult status); @Override IAroDevice[] getDevices(StatusResult status); @Override boolean isDeviceDataPulled();  }