com.google.common.truth.Subject.isNull()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(105)

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

Subject.isNull介绍

[英]Fails if the subject is not null.
[中]如果主题不为null,则失败。

代码示例

代码示例来源:origin: google/guava

public void testOnlyElementNull() {
 assertThat(Stream.of((Object) null).collect(MoreCollectors.onlyElement())).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
 public void testGetResourceFetcher_withEmptyString_returnsNull() {
  assertThat(loader.buildLoadData("", IMAGE_SIDE, IMAGE_SIDE, options)).isNull();
  assertThat(loader.buildLoadData("    ", IMAGE_SIDE, IMAGE_SIDE, options)).isNull();
  assertThat(loader.buildLoadData("  \n", IMAGE_SIDE, IMAGE_SIDE, options)).isNull();
 }
}

代码示例来源:origin: bumptech/glide

@Test
  public void testDoesNotThrowOnInvalidOrMissingId() {
   assertThat(loader.buildLoadData(1234, 0, 0, options)).isNull();
   verify(uriLoader, never()).buildLoadData(any(Uri.class), anyInt(), anyInt(),
     any(Options.class));
  }
}

代码示例来源:origin: bumptech/glide

@Test
public void obtain_withNullBitmapResource_returnsNull() {
 assertThat(LazyBitmapDrawableResource.obtain(resources, null)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void get_withMissingKey_returnsNull() {
 assertThat(resources.get(key)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void activate_withNonCacheableResource_doesNotSaveResource() {
 EngineResource<Object> engineResource =
   new EngineResource<>(resource, /*isCacheable=*/ false, /*isRecyclable=*/ true);
 resources.activate(key, engineResource);
 assertThat(resources.activeEngineResources.get(key).resource).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void testDoesNotPutResourceThatIsNotCacheableInActiveResourcesOnEngineComplete() {
 when(harness.resource.isCacheable()).thenReturn(false);
 harness.callOnEngineJobComplete();
 assertThat(harness.activeResources.get(harness.cacheKey)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getError_afterSettingErrorId_returnsNull() {
 assertThat(
   options
     .error(new ColorDrawable(Color.RED))
     .error(android.R.drawable.star_on)
     .getErrorPlaceholder())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getPlaceholder_afterSettingPlaceholderId_returnsNul() {
 assertThat(
   options
     .placeholder(new ColorDrawable(Color.RED))
     .placeholder(android.R.drawable.star_on)
     .getPlaceholderDrawable())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getFallback_afterSettingFallbackId_returnsNull() {
 assertThat(
   options
     .fallback(new ColorDrawable(Color.RED))
     .fallback(android.R.drawable.star_on)
     .getFallbackDrawable())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void clear_withSingleRequest_nullsOutDrawableInView() {
 concurrency.loadOnMainThread(
   GlideApp.with(context)
     .load(ResourceIds.raw.canonical),
   imageView);
 assertThat(imageView.getDrawable()).isNotNull();
 concurrency.clearOnMainThread(imageView);
 assertThat(imageView.getDrawable()).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void testDoesNotPutNullResourceInActiveResourcesOnEngineComplete() {
 harness.getEngine().onEngineJobComplete(harness.job, harness.cacheKey, /*resource=*/ null);
 assertThat(harness.activeResources.get(harness.cacheKey)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void queueIdle_withNotCacheableResourceInActive_removesResourceFromActive() {
 EngineResource<Object> engineResource =
   new EngineResource<>(resource, /*isCacheable=*/ false, /*isRecyclable=*/ true);
 resources.activate(key, engineResource);
 ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
 enqueueAndWaitForRef(weakRef);
 assertThat(resources.get(key)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void queueIdle_withCacheableResourceInActive_removesResourceFromActive() {
 EngineResource<Object> engineResource =
   new EngineResource<>(resource, /*isCacheable=*/ true, /*isRecyclable=*/ true);
 resources.activate(key, engineResource);
 ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
 enqueueAndWaitForRef(weakRef);
 assertThat(resources.get(key)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void get_withActiveAndClearedKey_returnsNull() {
 EngineResource<Object> engineResource =
   new EngineResource<>(resource, /*isCacheable=*/ true, /*isRecyclable=*/ true);
 resources.activate(key, engineResource);
 resources.activeEngineResources.get(key).clear();
 assertThat(resources.get(key)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getFallback_afterApplyingOptionsWithFallbackId_returnsNull() {
 RequestOptions toApply = new RequestOptions().fallback(android.R.drawable.star_on);
 assertThat(
   options
     .fallback(new ColorDrawable(Color.RED))
     .apply(toApply)
     .getFallbackDrawable())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getPlaceholder_afterApplyingOptionsWithPlaceholderId_returnsNull() {
 RequestOptions toApply = new RequestOptions().placeholder(android.R.drawable.star_on);
 assertThat(
   options
     .placeholder(new ColorDrawable(Color.RED))
     .apply(toApply)
     .getPlaceholderDrawable())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void getError_afterApplyingOptionsWithErrorId_returnsNull() {
 RequestOptions toApply = new RequestOptions().error(android.R.drawable.star_on);
 assertThat(
   options
     .error(new ColorDrawable(Color.RED))
     .apply(toApply)
     .getErrorPlaceholder())
   .isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void get_withDeactivatedKey_returnsNull() {
 EngineResource<Object> engineResource =
   new EngineResource<>(resource, /*isCacheable=*/ true, /*isRecyclable=*/ true);
 resources.activate(key, engineResource);
 resources.deactivate(key);
 assertThat(resources.get(key)).isNull();
}

代码示例来源:origin: bumptech/glide

@Test
public void testResourceIsRemovedFromActiveResourcesWhenReleased() {
 harness.activeResources.activate(harness.cacheKey, harness.resource);
 harness.getEngine().onResourceReleased(harness.cacheKey, harness.resource);
 assertThat(harness.activeResources.get(harness.cacheKey)).isNull();
}

相关文章