@@ -47,10 +47,9 @@ public String getName() {
4747 return "testdroid" ;
4848 }
4949
50- private APIProject searchProject (String projectName , APIProject . Type type , APIListResource <APIProject > projectList ) throws APIException {
50+ private APIProject searchProject (String projectName , APIListResource <APIProject > projectList ) throws APIException {
5151 if (projectList == null || projectList .getTotal () == 0 || projectList .getEntity () == null ||
5252 projectList .getEntity ().getData () == null ) {
53-
5453 return null ;
5554 }
5655
@@ -118,14 +117,13 @@ public void uploadApks(@NonNull String variantName, @NonNull File testApk, @Null
118117 try {
119118 if (extension .getProjectName () == null ) {
120119 logger .warn ("TESTDROID: Project name is not set - creating a new one" );
121- APIProject .Type type = getProjectType (extension .getMode ());
122- project = user .createProject (type );
120+ project = user .createProject (APIProject .Type .ANDROID );
123121 logger .info ("TESTDROID: Created project:" + project .getName ());
124122 } else {
125123 APIListResource <APIProject > projectList ;
126124 projectList = user .getProjectsResource ();
127125
128- project = searchProject (extension .getProjectName (), getProjectType ( extension . getMode ()), projectList );
126+ project = searchProject (extension .getProjectName (), projectList );
129127 if (project == null ) {
130128 logger .warn ("TESTDROID: Can't find project " + extension .getProjectName ());
131129 return ;
@@ -159,7 +157,7 @@ && new File(extension.getFullRunConfig().getInstrumentationAPKPath()).exists())
159157 instrumentationAPK = new File (extension .getFullRunConfig ().getInstrumentationAPKPath ());
160158 logger .info ("TESTDROID: Using custom path for instrumentation APK: %s" , extension .getFullRunConfig ().getInstrumentationAPKPath ());
161159 }
162- uploadBinaries (project , getProjectType ( extension . getMode ()), instrumentationAPK , testedApk );
160+ uploadBinaries (project , instrumentationAPK , testedApk );
163161
164162 project .run (extension .getTestRunName () == null ? variantName : extension .getTestRunName ());
165163
@@ -211,51 +209,40 @@ private HttpHost buildProxyHost() {
211209 return new HttpHost (proxyHost , port );
212210 }
213211
214- private void uploadBinaries (APIProject project , APIProject . Type projectType , File testApk , File testedApk ) throws APIException {
212+ private void uploadBinaries (APIProject project , File testApk , File testedApk ) throws APIException {
215213
216214 if (project .getType ().equals (APIProject .Type .UIAUTOMATOR )) {
217215
218- UIAutomatorFiles uiAutomatorFiles = project .getFiles (UIAutomatorFiles .class );
219216 if (extension .getUiAutomatorTestConfig () == null || extension .getUiAutomatorTestConfig ().getUiAutomatorJarPath () == null ) {
220217 throw new APIException ("TESTDROID: Configure uiautomator settings" );
221218 }
222219 File jarFile = new File (extension .getUiAutomatorTestConfig ().getUiAutomatorJarPath ());
223220 if (!jarFile .exists ()) {
224221 throw new APIException ("TESTDROID: Invalid uiAutomator jar file:" + jarFile .getAbsolutePath ());
225222 }
226- uiAutomatorFiles .uploadTest (new File (extension .getUiAutomatorTestConfig ().getUiAutomatorJarPath ()));
223+ project .uploadTest (new File (extension .getUiAutomatorTestConfig ().getUiAutomatorJarPath ()), "application/octet-stream" );
227224 logger .info ("TESTDROID: uiautomator file uploaded" );
228- uiAutomatorFiles . uploadApp (testedApk );
225+ project . uploadApplication (testedApk , "application/octet-stream" );
229226 logger .info ("TESTDROID: Android application uploaded" );
230227 } else {
231- AndroidFiles androidFiles = project .getFiles (AndroidFiles .class );
232228
233229 if (testedApk != null && testedApk .exists ()) {
234- androidFiles . uploadApp (testedApk );
230+ project . uploadApplication (testedApk , "application/octet-stream" );
235231 logger .info ("TESTDROID: Android application uploaded" );
236232 } else {
237233 logger .warn ("TESTDROID: Target application has not been added - uploading only test apk " );
238234 }
239235
240- if (testApk != null && APIProject .Type .ANDROID == projectType ) {
241- androidFiles .uploadTest (testApk );
236+ if (testApk != null && APIProject .Type .ANDROID == project . getType () ) {
237+ project .uploadTest (testApk , "application/octet-stream" );
242238 logger .info ("TESTDROID: Android test uploaded" );
243239 return ;
244240 }
245241 }
246242
247243 }
248244
249- private APIProject .Type getProjectType (String testrunMode ) throws APIException {
250- if (APITestRunConfig .Mode .FULL_RUN .name ().equals (testrunMode ) || APITestRunConfig .Mode .APP_CRAWLER .name ().equals (testrunMode )) {
251- return APIProject .Type .ANDROID ;
252- } else if (APITestRunConfig .Mode .UIAUTOMATOR .name ().equals (testrunMode )) {
253- return APIProject .Type .UIAUTOMATOR ;
254- } else {
255- throw new APIException ("TESTDROID: Not supported test run mode:" + testrunMode + " Enum" + APITestRunConfig .Mode .FULL_RUN .name ());
256- }
257245
258- }
259246
260247 private APITestRunConfig updateAPITestRunConfigValues (APIProject project , TestDroidExtension extension , Long deviceGroupId ) throws APIException {
261248
@@ -264,8 +251,10 @@ private APITestRunConfig updateAPITestRunConfigValues(APIProject project, TestDr
264251 config .setHookURL (extension .getHookUrl ());
265252 config .setDeviceLanguageCode (extension .getDeviceLanguageCode ());
266253 config .setScheduler (extension .getScheduler () != null ? APITestRunConfig .Scheduler .valueOf (extension .getScheduler ()) : null );
254+ if (extension .getMode () != null ) {
255+ logger .warn ("TESTDROID: mode variable is not used anymore" );
256+ }
267257
268- config .setMode (APITestRunConfig .Mode .valueOf (extension .getMode ()));
269258 //App crawler settings
270259 config .setApplicationUsername (extension .getAppCrawlerConfig ().getApplicationUserName ());
271260 config .setApplicationPassword (extension .getAppCrawlerConfig ().getApplicationPassword ());
@@ -307,9 +296,8 @@ public boolean isConfigured() {
307296 if (extension .getProjectName () == null ) {
308297 logger .warn ("TESTDROID: project name has not been set, creating a new project" );
309298 }
310- if (extension .getMode () == null || APITestRunConfig .Mode .valueOf (extension .getMode ()) == null ) {
311- logger .warn ("TESTDROID: Test run mode has not been set(default: FULL_RUN)" );
312- extension .setMode (APITestRunConfig .Mode .FULL_RUN .name ());
299+ if (extension .getMode () != null ) {
300+ logger .warn ("TESTDROID: mode variable is not used anymore" );
313301 }
314302 if (extension .getDeviceGroup () == null ) {
315303 logger .warn ("TESTDROID: Device group has not been set" );
0 commit comments