• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Assertions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.assertj.android.api.Assertions的典型用法代码示例。如果您正苦于以下问题:Java Assertions类的具体用法?Java Assertions怎么用?Java Assertions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Assertions类属于org.assertj.android.api包,在下文中一共展示了Assertions类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: whenShown_thenButtonsTextsCorrect

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void whenShown_thenButtonsTextsCorrect() {
  String positive = "126kas";
  String neutral = "12asi";
  String negative = "98io8";

  DialogFields fields = DialogFields.builder(activity)
      .positiveText(positive)
      .neutralText(neutral)
      .negativeText(negative)
      .build();

  LambdaDialogs.delegate(activity)
      .parameter(fields)
      .method(new AlertDialogFactory<>())
      .show();

  AlertDialog dialog = (AlertDialog) ShadowDialog.getLatestDialog();
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_POSITIVE)).hasText(positive);
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_NEUTRAL)).hasText(neutral);
  Assertions.assertThat(dialog.getButton(AlertDialog.BUTTON_NEGATIVE)).hasText(negative);
}
 
开发者ID:jraska,项目名称:lambda-dialogs,代码行数:23,代码来源:LambdaDialogsBuilderTest.java


示例2: testEmptyResponse

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testEmptyResponse() {
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager()
            .beginTransaction()
            .add(android.R.id.list,
                    Fragment.instantiate(activity, ListFragment.class.getName(), args))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onResponse(new Item[0]);
    assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:19,代码来源:ListFragmentTest.java


示例3: testErrorResponse

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testErrorResponse() {
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager()
            .beginTransaction()
            .add(android.R.id.list,
                    Fragment.instantiate(activity, ListFragment.class.getName(), args))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onError(null);
    assertThat((SwipeRefreshLayout) activity.findViewById(R.id.swipe_layout)).isNotRefreshing();
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isVisible();
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:19,代码来源:ListFragmentTest.java


示例4: givenActionTextAndClickListener_whenBuildWrapper_thenActionTextAndClickListenerSet

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenActionTextAndClickListener_whenBuildWrapper_thenActionTextAndClickListenerSet() {
  RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme);
  CoordinatorLayout parent = new CoordinatorLayout(RuntimeEnvironment.application);

  SnackbarWrapper wrapper = new SnackbarBuilder(parent)
      .actionText("action")
      .actionClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
          view.setBackgroundColor(Color.RED);
        }
      })
      .buildWrapper();

  assertThat(wrapper.getActionText()).isEqualTo("action");
  View actionView = wrapper.getView().findViewById(R.id.snackbar_action);
  actionView.performClick();
  Assertions.assertThat((ColorDrawable) actionView.getBackground()).hasColor(Color.RED);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:21,代码来源:SnackbarBuilderTest.java


示例5: givenIcon_whenBuild_thenIconAddedToSnackbar

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenIcon_whenBuild_thenIconAddedToSnackbar() {
  RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme);
  CoordinatorLayout parent = new CoordinatorLayout(RuntimeEnvironment.application);

  Snackbar snackbar = new SnackbarBuilder(parent)
      .message("messsage")
      .icon(drawable)
      .iconMargin(10)
      .build();

  TextView messageView = (TextView) snackbar.getView().findViewById(R.id.snackbar_text);
  Assertions.assertThat(messageView)
      .hasCompoundDrawablePadding(10);
  assertThat(messageView.getCompoundDrawables()[0]).isEqualTo(drawable);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:17,代码来源:SnackbarBuilderTest.java


示例6: testRefreshError

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void testRefreshError() {
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager()
            .beginTransaction()
            .add(android.R.id.list,
                    Fragment.instantiate(activity, ListFragment.class.getName(), args))
            .commit();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_DEFAULT),
            listener.capture());
    listener.getValue().onResponse(new Item[]{new TestItem() {}});
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    reset(itemManager);
    ShadowSwipeRefreshLayout shadowSwipeRefreshLayout = (ShadowSwipeRefreshLayout)
            ShadowExtractor.extract(activity.findViewById(R.id.swipe_layout));
    shadowSwipeRefreshLayout.getOnRefreshListener().onRefresh();
    verify(itemManager).getStories(any(),
            eq(ItemManager.MODE_NETWORK),
            listener.capture());
    listener.getValue().onError(null);
    Assertions.assertThat((View) activity.findViewById(R.id.empty)).isNotVisible();
    assertNotNull(ShadowToast.getLatestToast());
    controller.pause().stop().destroy();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:28,代码来源:ListFragmentTest.java


示例7: count

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void count() {
    List<Persona> personas = generatePersonas();

    PersonasAdapter personasAdapter = new PersonasAdapter(context, personas);

    Assertions.assertThat(personasAdapter).hasCount(personas.size());
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:9,代码来源:PersonasAdapterTester.java


示例8: item

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void item() {
    Persona persona = generatePersona();

    List<Persona> personas = new ArrayList<>();
    personas.add(persona);
    personas.addAll(generatePersonas());

    PersonasAdapter personasAdapter = new PersonasAdapter(context, personas);

    Assertions.assertThat(personasAdapter).hasItem(persona, 0);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:13,代码来源:PersonasAdapterTester.java


示例9: alerts

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void alerts() {
    Intent intent = Intents.Builder.of(context).buildAlertsIntent(generateResource());

    Assertions.assertThat(intent).hasComponent(context, AlertsActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:IntentsTester.java


示例10: metric

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metric() {
    Intent intent = Intents.Builder.of(context).buildMetricIntent(generateMetric());

    Assertions.assertThat(intent).hasComponent(context, MetricActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.METRIC);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:IntentsTester.java


示例11: metrics

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metrics() {
    Intent intent = Intents.Builder.of(context).buildMetricsIntent(generateEnvironment(), generateResource());

    Assertions.assertThat(intent).hasComponent(context, MetricsActivity.class);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.ENVIRONMENT);
    Assertions.assertThat(intent).hasExtra(Intents.Extras.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:9,代码来源:IntentsTester.java


示例12: metrics

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void metrics() {
    Fragment fragment = Fragments.Builder.buildMetricsFragment(generateEnvironment(), generateResource());

    Assertions.assertThat(fragment.getArguments()).hasKey(Fragments.Arguments.ENVIRONMENT);
    Assertions.assertThat(fragment.getArguments()).hasKey(Fragments.Arguments.RESOURCE);
}
 
开发者ID:hawkular,项目名称:hawkular-android-client,代码行数:8,代码来源:FragmentsTester.java


示例13: givenClickListener_whenSetActionWithResource_thenActionSetAndShown

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenClickListener_whenSetActionWithResource_thenActionSetAndShown() {
  TestClickListener clickListener = new TestClickListener();

  wrapper.setAction(R.string.snackbarbuilder_action_undo, clickListener);

  Assertions.assertThat(getActionView())
      .isVisible()
      .hasText("Undo");
  getActionView().performClick();
  assertThat(clickListener.isClicked()).isTrue();
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:13,代码来源:SnackbarWrapperTest.java


示例14: givenClickListener_whenSetAction_thenActionSetAndShown

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void givenClickListener_whenSetAction_thenActionSetAndShown() {
  TestClickListener clickListener = new TestClickListener();
  String actionText = "some action";

  wrapper.setAction(actionText, clickListener);

  Assertions.assertThat(getActionView())
      .isVisible()
      .hasText(actionText);
  getActionView().performClick();
  assertThat(clickListener.isClicked()).isTrue();
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:14,代码来源:SnackbarWrapperTest.java


示例15: whenSetBackgroundColor_thenBackgroundColorSet

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void whenSetBackgroundColor_thenBackgroundColorSet() {
  wrapper.setBackgroundColor(Color.MAGENTA);

  Assertions.assertThat((ColorDrawable) wrapper.getView().getBackground())
      .hasColor(Color.MAGENTA);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:8,代码来源:SnackbarWrapperTest.java


示例16: whenSetBackgroundColorResId_thenBackgroundColorSet

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void whenSetBackgroundColorResId_thenBackgroundColorSet() {
  wrapper.setBackgroundColorRes(R.color.snackbarbuilder_default_message);

  Assertions.assertThat((ColorDrawable) wrapper.getView().getBackground())
      .hasColor(Color.WHITE);
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:8,代码来源:SnackbarWrapperTest.java


示例17: whenBuild_thenSnackbarSetup

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
@TargetApi(11)
public void whenBuild_thenSnackbarSetup() {
  int messageTextColor = 0xFF111111;
  int actionTextColor = 0xFF999999;
  int backgroundCOlor = 0xFF777777;
  String message = "message";
  String action = "action";
  RuntimeEnvironment.application.setTheme(R.style.TestSnackbarBuilder_AppTheme);
  CoordinatorLayout parent = new CoordinatorLayout(RuntimeEnvironment.application);

  Snackbar snackbar = new SnackbarBuilder(parent)
      .messageTextColor(messageTextColor)
      .actionTextColor(actionTextColor)
      .message(message)
      .actionText(action)
      .duration(Snackbar.LENGTH_INDEFINITE)
      .backgroundColor(backgroundCOlor)
      .actionAllCaps(false)
      .build();

  assertThat(snackbar.getDuration()).isEqualTo(Snackbar.LENGTH_INDEFINITE);

  Assertions.assertThat((TextView) snackbar.getView().findViewById(R.id.snackbar_text))
      .hasCurrentTextColor(messageTextColor)
      .hasText(message);

  Assertions.assertThat((ColorDrawable) snackbar.getView().getBackground())
      .hasColor(backgroundCOlor);

  Button button = (Button) snackbar.getView().findViewById(R.id.snackbar_action);
  Assertions.assertThat(button).hasCurrentTextColor(actionTextColor);
  button.performClick();
  assertThat(button.getTransformationMethod()).isNull();
}
 
开发者ID:andrewlord1990,项目名称:SnackbarBuilder,代码行数:36,代码来源:SnackbarBuilderTest.java


示例18: should_be_disable_on_state_connected

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void should_be_disable_on_state_connected() throws Exception {
    // Given

    // When
    activity.setStateLogged();

    // Then
    Assertions.assertThat(activity.loginEditText).isDisabled();
    Assertions.assertThat(activity.passwordEditText).isDisabled();
    Assertions.assertThat(activity.connectButton).isDisabled();
}
 
开发者ID:blacroix,项目名称:droidcon_android_tests,代码行数:13,代码来源:FormActivityTest.java


示例19: deleteByQueryExecuteAsBlocking

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void deleteByQueryExecuteAsBlocking() {
    TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();

    storIOContentResolver
            .observeChangesOfUri(TestItem.CONTENT_URI, BackpressureStrategy.MISSING)
            .take(2)
            .subscribe(changesTestSubscriber);

    TestItem testItemToInsert = TestItem.create(null, "value");
    contentResolver.insert(TestItem.CONTENT_URI, testItemToInsert.toContentValues());

    Cursor firstDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
    Assertions.assertThat(firstDbState).hasCount(1);

    DeleteResult deleteResult = storIOContentResolver
            .delete()
            .byQuery(DeleteQuery.builder()
                    .uri(TestItem.CONTENT_URI)
                    .build())
            .prepare()
            .executeAsBlocking();

    assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);

    Cursor secondDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
    Assertions.assertThat(secondDbState).hasCount(0);

    changesTestSubscriber.awaitTerminalEvent(60, SECONDS);
    changesTestSubscriber.assertNoErrors();
    changesTestSubscriber.assertValues(Changes.newInstance(TestItem.CONTENT_URI), Changes.newInstance(TestItem.CONTENT_URI));
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:33,代码来源:DeleteOperationTest.java


示例20: deleteByQueryAsRxFlowable

import org.assertj.android.api.Assertions; //导入依赖的package包/类
@Test
public void deleteByQueryAsRxFlowable() {
    TestSubscriber<Changes> changesTestSubscriber = new TestSubscriber<Changes>();

    storIOContentResolver
            .observeChangesOfUri(TestItem.CONTENT_URI, BackpressureStrategy.MISSING)
            .take(2)
            .subscribe(changesTestSubscriber);

    TestItem testItemToInsert = TestItem.create(null, "value");
    contentResolver.insert(TestItem.CONTENT_URI, testItemToInsert.toContentValues());

    Cursor firstDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
    Assertions.assertThat(firstDbState).hasCount(1);

    DeleteResult deleteResult = storIOContentResolver
            .delete()
            .byQuery(DeleteQuery.builder()
                    .uri(TestItem.CONTENT_URI)
                    .build())
            .prepare()
            .asRxFlowable(BackpressureStrategy.MISSING)
            .blockingFirst();

    assertThat(deleteResult.numberOfRowsDeleted()).isEqualTo(1);

    Cursor secondDbState = contentResolver.query(TestItem.CONTENT_URI, null, null, null, null);
    Assertions.assertThat(secondDbState).hasCount(0);

    changesTestSubscriber.awaitTerminalEvent(60, SECONDS);
    changesTestSubscriber.assertNoErrors();
    changesTestSubscriber.assertValues(Changes.newInstance(TestItem.CONTENT_URI), Changes.newInstance(TestItem.CONTENT_URI));
}
 
开发者ID:pushtorefresh,项目名称:storio,代码行数:34,代码来源:DeleteOperationTest.java



注:本文中的org.assertj.android.api.Assertions类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SessionBuilder类代码示例发布时间:2022-05-22
下一篇:
Java TestDirHelper类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap