package org.fest.assertions.api.android.content;

import android.content.Intent;
import org.fest.assertions.api.AbstractAssert;

import static org.fest.assertions.api.Assertions.assertThat;

/** Assertions for {@link Intent} instances. */
public class IntentAssert extends AbstractAssert<IntentAssert, Intent> {
  public IntentAssert(Intent actual) {
    super(actual, IntentAssert.class);
  }

  public IntentAssert hasAction(String action) {
    isNotNull();
    String actualAction = actual.getAction();
    assertThat(actualAction) //
        .overridingErrorMessage("Expected action <%s> but was <%s>.", action, actualAction) //
        .isEqualTo(action);
    return this;
  }

  public IntentAssert hasType(String type) {
    isNotNull();
    String actualType = actual.getType();
    assertThat(actualType) //
        .overridingErrorMessage("Expected type <%s> but was <%s>.", type, actualType) //
        .isEqualTo(type);
    return this;
  }

  public IntentAssert hasExtra(String name) {
    isNotNull();
    assertThat(actual.hasExtra(name)) //
        .overridingErrorMessage("Expected extra <%s> to be present but was not present.", name) //
        .isTrue();
    return this;
  }
}

@@ -1191,10 +1191,2374 @@
 is;%0A  %7D%0A
+%0A  public IntentAssert hasFlags(int flags) %7B%0A    int expected = actual.getFlags();%0A    assertThat(expected)%0A      .overridingErrorMessage(%22Expected %3C%25s%3E but was %3C%25s%3E.%22, flagToString(expected), flagToString(flags))%0A      .isEqualTo(flags);%0A    return this;%0A  %7D%0A%0A  public static String flagToString(int flag) %7B%0A    switch(flag) %7B%0A      case Intent.FLAG_GRANT_READ_URI_PERMISSION:%0A        return %22grant_read_uri_permission%22;%0A      case Intent.FLAG_GRANT_WRITE_URI_PERMISSION:%0A        return %22grant_write_uri_permission%22;%0A      case Intent.FLAG_DEBUG_LOG_RESOLUTION:%0A        return %22debug_log_resolution%22;%0A      case Intent.FLAG_FROM_BACKGROUND:%0A        return %22from_background%22;%0A      case Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT:%0A        return %22activity_brought_to_front%22;%0A      case Intent.FLAG_ACTIVITY_CLEAR_TASK:%0A        return %22activity_clear_task%22;%0A      case Intent.FLAG_ACTIVITY_CLEAR_TOP:%0A        return %22activity_clear_top%22;%0A      case Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET:%0A        return %22activity_clear_when_task_reset%22;%0A      case Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS:%0A        return %22activity_exclude_from_recents%22;%0A      case Intent.FLAG_ACTIVITY_FORWARD_RESULT:%0A        return %22activity_forward_result%22;%0A      case Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY:%0A        return %22activity_launched_from_history%22;%0A      case Intent.FLAG_ACTIVITY_MULTIPLE_TASK:%0A        return %22activity_multiple_task%22;%0A      case Intent.FLAG_ACTIVITY_NEW_TASK:%0A        return %22activity_new_task%22;%0A      case Intent.FLAG_ACTIVITY_NO_ANIMATION:%0A        return %22activity_no_animation%22;%0A      case Intent.FLAG_ACTIVITY_NO_HISTORY:%0A        return %22activity_no_history%22;%0A      case Intent.FLAG_ACTIVITY_NO_USER_ACTION:%0A        return %22activity_no_user_action%22;%0A      case Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP:%0A        return %22activity_previous_is_top%22;%0A      case Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED:%0A        return %22activity_reset_task_if_needed%22;%0A      case Intent.FLAG_ACTIVITY_REORDER_TO_FRONT:%0A        return %22activity_reorder_to_front%22;%0A      case Intent.FLAG_ACTIVITY_SINGLE_TOP:%0A        return %22activity_single_top%22;%0A      case Intent.FLAG_ACTIVITY_TASK_ON_HOME:%0A        return %22activity_task_on_home%22;%0A      //  case Intent.FLAG_RECEIVER_REGISTERED_ONLY:%0A      //    return %22receiver_registered_only%22;%0A      default:%0A        return flag + %22%22;%0A    %7D%0A  %7D%0A%0A
 %7D%0A

Add IntentAssert.hasFlags()