public void testRequiredEmpty() throws Exception { boolean success = false; try { persister.read(RequiredElement.class, EMPTY_ELEMENT); } catch(ValueRequiredException e) { e.printStackTrace(); success = true; } assertTrue(success); }
public void testRequiredEmptyMethod() throws Exception { boolean success = false; try { persister.read(RequiredMethodElement.class, EMPTY_ELEMENT); } catch(ValueRequiredException e) { e.printStackTrace(); success = true; } assertTrue(success); }
public void testRequiredBlank() throws Exception { boolean success = false; try { persister.read(RequiredElement.class, BLANK_ELEMENT); } catch(ValueRequiredException e) { e.printStackTrace(); success = true; } assertTrue(success); }
public void testOptionalEmpty() throws Exception { boolean success = false; try { persister.read(RequiredElement.class, EMPTY_ELEMENT); } catch(ValueRequiredException e) { e.printStackTrace(); success = true; } assertTrue(success); }
/** * Validates the data read from the XML document by checking that when <code>MaxRetries</code> is supplied * <code>RetryInterval</code> contains positive non zero value;</li></ol> * * @throws Exception When the read XML is not valid */ @Validate public void validate() throws Exception { if (maxRetries > -1) if (retryIntervalDuration <= 0) throw new ValueRequiredException("ReceptionAwareness/RetryInterval must have positive non zero value"); }
/** * This function is called in a background thread and should generate a new set of * data to be published by the loader. * <p> * This is where the heavy work is done. */ @Override public List<BookWrapper> loadInBackground() { // retrieve the books. books = new ArrayList<>(); if(searchQuery != null && !searchQuery.isEmpty()){ Log.d(TAG, "started with: "+searchQuery); GoodreadsService goodreadsService = retrofit.create(GoodreadsService.class); Call<GoodreadsResponse> call = goodreadsService.searchBooks(searchQuery, 1, BuildConfig.GoodreadsApiKey); try { GoodreadsResponse response = call.execute().body(); books = response.getSearch().getResults().getBookWrappers(); } catch (Exception e) { if(e instanceof IOException || e instanceof ValueRequiredException) { Log.e(TAG, "loadInBackground: ", e ); books = Collections.emptyList(); return books; }else{ Log.e(TAG, "loadInBackground: another exeption ", e); e.printStackTrace(); books = Collections.emptyList(); return books; } } Log.d(TAG, "loadInBackground: Finished "); return books; }else{ Log.i(TAG, "loadInBackground: searchQuery empty or null"); return books; } // return books; }