title: Unit Testing in Retrofit for Callback
body: <p>Here i got a sample of code in presenter. How do i make write a test for onSuccess and onFailure in retrofit call</p>
  
  <pre><code>public void getNotifications(final List&lt;HashMap&lt;String,Object&gt;&gt; notifications){
  
          if (!"".equalsIgnoreCase(userDB.getValueFromSqlite("email",1))) {
              UserNotifications userNotifications =
                      new UserNotifications(userDB.getValueFromSqlite("email",1),Integer.parseInt(userDB.getValueFromSqlite("userId",1).trim()));
              Call call = apiInterface.getNotifications(userNotifications);
              call.enqueue(new Callback() {
                  @Override
                  public void onResponse(Call call, Response response) {
                      UserNotifications userNotifications1 = (UserNotifications) response.body();
  
  
                      if(userNotifications1.getNotifications().isEmpty()){
                          view.setListToAdapter(notifications);
                          onFailure(call,new Throwable());
                      }
                      else {
                          for (UserNotifications.Datum datum:userNotifications1.getNotifications()) {
                              HashMap&lt;String,Object&gt; singleNotification= new HashMap&lt;&gt;();
                              singleNotification.put("notification",datum.getNotification());
                              singleNotification.put("date",datum.getDate());
                              notifications.add(singleNotification);
                          }
                          view.setListToAdapter(notifications);
                      }
                  }
  
                  @Override
                  public void onFailure(Call call, Throwable t) {
                      call.cancel();
                  }
              });
          }
      }
  
  }
  </code></pre>
  
  <p>How do i write unittesting to cover all cases for this piece of code.</p>
  
  <p>Thanks</p>