org.assertj.core.api.AbstractListAssert.isNotNull()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(93)

本文整理了Java中org.assertj.core.api.AbstractListAssert.isNotNull()方法的一些代码示例,展示了AbstractListAssert.isNotNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractListAssert.isNotNull()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractListAssert
类名称:AbstractListAssert
方法名:isNotNull

AbstractListAssert.isNotNull介绍

暂无

代码示例

代码示例来源:origin: facebook/litho

/**
 * Tests if any view in the hierarchy under the root, for which the path is visible, has the
 * requested piece of text as its text and has a tag set on that TextView with the given tag id
 * and tag value.
 *
 * @param text the text to search for
 * @param tagId the tag to look for on the TextView containing the searched text
 * @param tagValue the expected value of the tag associated with tagId
 * @return the assertions object
 */
public ViewTreeAssert hasVisibleTextWithTag(final String text, final int tagId, final Object tagValue) {
 final ImmutableList<View> path = getPathToVisibleTextWithTag(text, tagId, tagValue);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Cannot find text \"%s\" with tagId \"%d\" and value:%s in view hierarchy:%n%s",
     text,
     tagId,
     tagValue.toString(),
     actual.makeString(GET_TEXT_FUNCTION))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/**
 * Tests if any view in the hierarchy under the root, for which the path is visible, has the
 * requested piece of text as its text
 *
 * @param text the text to search for
 * @return the assertions object
 */
public ViewTreeAssert hasVisibleText(final String text) {
 final ImmutableList<View> path = getPathToVisibleText(text);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(path == null ? getHasVisibleTextErrorMessage(text) : "")
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/**
 * Tests if any view hierarchy under the root has the given contentDescription.
 * @param contentDescription the contentDescription to search for
 * @return the assertions object
 */
public ViewTreeAssert hasContentDescription(final String contentDescription) {
 final ImmutableList<View> path = getPathToContentDescription(contentDescription);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Cannot find content description \"%s\" in view hierarchy:%n%s",
     contentDescription,
     actual.makeString(ViewExtractors.GET_CONTENT_DESCRIPTION_FUNCTION))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/**
 * Tests if any view in the hierarchy under the root, for which the path is visible, has text that
 * matches the given regular expression
 *
 * @param pattern the regular expression to match against
 * @return the assertions object
 */
public ViewTreeAssert hasVisibleTextMatching(final String pattern) {
 final ImmutableList<View> path = getPathToVisibleMatchingText(pattern);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Cannot find text matching \"%s\" in view hierarchy:%n%s",
     pattern,
     actual.makeString(GET_TEXT_FUNCTION))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/**
 * Tests if any view in the hierarchy under the root, for which the path is visible, is displaying
 * the requested drawable
 *
 * @param drawable the drawable to look for
 * @return the assertions object
 */
public ViewTreeAssert hasVisibleDrawable(final Drawable drawable) {
 final ImmutableList<View> path = getPathToVisibleWithDrawable(drawable);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Did not find drawable %s in view hierarchy:%n%s",
     drawable,
     actual.makeString(ViewExtractors.GET_DRAWABLE_FUNCTION))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/** Whether there is a visible view in the hierarchy with the given id. */
public ViewTreeAssert hasVisibleViewWithId(final int viewId) {
 final ImmutableList<View> path = getPathToVisibleWithId(viewId);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Did not find visible view with id \"%s=%d\":%n%s",
     ViewTreeUtil.getResourceName(viewId),
     viewId,
     actual.makeString(ViewExtractors.GET_VIEW_ID_FUNCTION))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

public <V extends View> ViewTreeAssert hasVisible(final Class<V> clazz, final Predicate<V> predicate) {
 final Predicate<View> conjunction = Predicates.and(
   Predicates.instanceOf(clazz),
   ViewPredicates.isVisible(),
   (Predicate<View>) predicate);
 final ImmutableList<View> path = actual.findChild(
   conjunction,
   ViewPredicates.isVisible());
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Did not find view for which given predicate is true in view hierarchy:%n%s",
     actual.makeString(null))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

/**
 * Tests if any view hierarchy under the root has the given view tag and value.
 * @param tagId the id to look for
 * @param tagValue the value that the id should have
 * @return the assertions object
 */
public ViewTreeAssert hasViewTag(final int tagId, final Object tagValue) {
 final ImmutableList<View> path = getPathToViewTag(tagId, tagValue);
 Java6Assertions.assertThat(path)
   .overridingErrorMessage(
     "Cannot find tag id \"%d\" with tag value \"%s\" in view hierarchy:%n%s",
     tagId,
     tagValue,
     actual.makeString(ViewExtractors.generateGetViewTagFunction(tagId)))
   .isNotNull();
 return this;
}

代码示例来源:origin: facebook/litho

@Test
public void testCreateChangeNullInList() {
 final List<RenderInfo> renderInfos = new ArrayList<>();
 renderInfos.add(ComponentRenderInfo.createEmpty());
 renderInfos.add(null);
 final Change change = Change.insertRange(0, 5, renderInfos);
 assertThat(change.getRenderInfo()).isNotNull();
 final List<RenderInfo> changeRenderInfos = change.getRenderInfos();
 assertThat(changeRenderInfos).isNotNull();
 assertThat(changeRenderInfos.get(0)).isNotNull();
 assertThat(changeRenderInfos.get(1)).isNotNull();
}

代码示例来源:origin: evernote/android-job

@Test
public void testCancel() {
  int jobId = new JobRequest.Builder(TAG)
      .setExecutionWindow(TimeUnit.HOURS.toMillis(4), TimeUnit.HOURS.toMillis(5))
      .build()
      .schedule();
  JobRequest request = mWorkManagerRule.getManager().getJobRequest(jobId);
  JobProxyWorkManager jobProxyWorkManager = new JobProxyWorkManager(InstrumentationRegistry.getTargetContext());
  assertThat(jobProxyWorkManager.isPlatformJobScheduled(request)).isTrue();
  String tag = JobProxyWorkManager.createTag(jobId);
  List<WorkInfo> statuses = mWorkManagerRule.getWorkStatus(tag);
  assertThat(statuses).isNotNull().hasSize(1);
  assertThat(statuses.get(0).getState()).isEqualTo(WorkInfo.State.ENQUEUED);
  mWorkManagerRule.getManager().cancel(jobId);
  assertThat(mWorkManagerRule.getWorkStatus(tag).get(0).getState()).isEqualTo(WorkInfo.State.CANCELLED);
  assertThat(jobProxyWorkManager.isPlatformJobScheduled(request)).isFalse();
}

代码示例来源:origin: facebook/litho

@Test
public void testCreateChangeNull() {
 final Change change = Change.insertRange(0, 5, null);
 assertThat(change.getRenderInfo()).isNotNull();
 assertThat(change.getRenderInfos()).isNotNull();
}

代码示例来源:origin: evernote/android-job

@Test
public void verifyAlarmNotCanceledForPeriodicAfterStart() throws Exception {
  assumeTrue(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);
  JobConfig.forceApi(JobApi.V_21);
  Bundle extras = new Bundle();
  extras.putString("key", "value");
  int jobId = new JobRequest.Builder("tag")
      .setPeriodic(TimeUnit.DAYS.toMillis(1))
      .setTransientExtras(extras)
      .build()
      .schedule();
  assertThat(mJobManagerRule.getAllPendingJobsFromScheduler()).isNotNull().isNotEmpty();
  JobRequest request = mJobManagerRule.getManager().getJobRequest(jobId);
  assertThat(request.isTransient()).isTrue();
  final Intent intent = PlatformAlarmServiceExact.createIntent(context(), jobId, null);
  PendingIntent pendingIntent = PendingIntent.getService(context(), jobId, intent, PendingIntent.FLAG_NO_CREATE);
  assertThat(pendingIntent).isNotNull();
  boolean started = TransientBundleCompat.startWithTransientBundle(context(), request);
  assertThat(started).isTrue();
  pendingIntent = PendingIntent.getService(context(), jobId, intent, PendingIntent.FLAG_NO_CREATE);
  assertThat(pendingIntent).isNotNull();
}

代码示例来源:origin: evernote/android-job

@SuppressWarnings("ConstantConditions")
  private void testConstraints(JobRequest.Builder builder) {
    int jobId = builder
        .setRequiredNetworkType(JobRequest.NetworkType.METERED)
        .setRequiresBatteryNotLow(true)
        .setRequiresCharging(true)
        .setRequiresDeviceIdle(true)
        .setRequiresStorageNotLow(true)
        .build()
        .schedule();

    String tag = JobProxyWorkManager.createTag(jobId);
    List<WorkInfo> statuses = mWorkManagerRule.getWorkStatus(tag);

    assertThat(statuses).isNotNull().hasSize(1);
    assertThat(statuses.get(0).getState()).isEqualTo(WorkInfo.State.ENQUEUED);

    mWorkManagerRule.getManager().cancelAllForTag(TAG);
    assertThat(mWorkManagerRule.getWorkStatus(tag).get(0).getState()).isEqualTo(WorkInfo.State.CANCELLED);
  }
}

代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core

/**
 * Validates that for each page the {@link ExecutionInfo} will have a different tracing ID.
 *
 * @test_category tracing
 * @expected_result {@link ResultSet} where all the {@link ExecutionInfo} will contains a
 *     different tracing ID and that the events can be retrieved for the last query.
 */
@Test(groups = "short")
public void should_have_a_different_tracingId_for_each_page() {
 SimpleStatement st = new SimpleStatement(String.format("SELECT v FROM test WHERE k='%s'", KEY));
 ResultSet result = session().execute(st.setFetchSize(40).enableTracing());
 result.all();
 // sleep 10 seconds to make sure the trace will be complete
 Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
 List<ExecutionInfo> executions = result.getAllExecutionInfo();
 UUID previousTraceId = null;
 for (ExecutionInfo executionInfo : executions) {
  QueryTrace queryTrace = executionInfo.getQueryTrace();
  assertThat(queryTrace).isNotNull();
  assertThat(queryTrace.getTraceId()).isNotEqualTo(previousTraceId);
  previousTraceId = queryTrace.getTraceId();
 }
 assertThat(result.getExecutionInfo().getQueryTrace().getEvents()).isNotNull().isNotEmpty();
}

代码示例来源:origin: spring-projects/spring-ldap

@Test
public void testList_PartialResultException_Ignore() throws NamingException {
  expectGetReadOnlyContext();
  javax.naming.PartialResultException pre = new javax.naming.PartialResultException();
  when(dirContextMock.list(NAME)).thenThrow(pre);
  tested.setIgnorePartialResultException(true);
  List list = tested.list(NAME);
  verify(dirContextMock).close();
  assertThat(list).isNotNull();
  assertThat(list).isEmpty();
}

代码示例来源:origin: rharter/auto-value-moshi

@Test
public void objectWithNullableClassAndJsonQualifier() throws Exception {
 JsonAdapter<WithNullableClassAndJsonQualifier> adapter =
     moshi.adapter(WithNullableClassAndJsonQualifier.class);
 WithNullableClassAndJsonQualifier fromJson = adapter.fromJson("{\"value\":\"value\","
     + "\"list\":[\"string1\",\"string2\"]}");
 assertThat(fromJson.value()).isEqualTo("value");
 assertThat(fromJson.list()).isNotNull();
 assertThat(fromJson.list().size()).isEqualTo(2);
 assertThat(fromJson.list()).containsExactly("string2", "string1");
}

代码示例来源:origin: Nike-Inc/wingtips

@Test
public void public_constructor_uses_empty_annotations_list_when_annotations_argument_is_null() {
  // when
  Span span = new Span(traceId, parentSpanId, spanId, spanName, true, userId, null, 42, null, null, null, null);
  // then
  assertThat(span.getTimestampedAnnotations())
    .isNotNull()
    .isEmpty();
}

代码示例来源:origin: apache/archiva

@Test
public void testRemoveFacetWhenEmpty()
  throws Exception
{
  List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
  assertThat( facets ).isNotNull().isEmpty();
  assertThat( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull();
  repository.removeMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME );
  facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID );
  assertThat( facets ).isNotNull().isEmpty();
  assertThat( repository.getMetadataFacet( TEST_REPO_ID, TEST_FACET_ID, TEST_NAME ) ).isNull();
}

代码示例来源:origin: apache/archiva

@Test
public void testGetArtifactsByDateRangeLowerBoundOutOfRange()
  throws Exception
{
  ArtifactMetadata artifact = createArtifact();
  repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
  Date date = new Date( artifact.getWhenGathered().getTime() + 10000 );
  List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, date, null );
  assertThat( artifacts ).isNotNull().isEmpty();
}

代码示例来源:origin: apache/archiva

@Test
public void testGetArtifactsByDateRangeUpperBoundOutOfRange()
  throws Exception
{
  ArtifactMetadata artifact = createArtifact();
  repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION, artifact );
  repository.save();
  Date upper = new Date( artifact.getWhenGathered().getTime() - 10000 );
  List<ArtifactMetadata> artifacts = repository.getArtifactsByDateRange( TEST_REPO_ID, null, upper );
  assertThat( artifacts ).isNotNull().isEmpty();
}

相关文章

微信公众号

最新文章

更多