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

x33g5p2x  于2022-01-16 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(126)

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

AbstractMapAssert.isEmpty介绍

[英]Verifies that the Map is empty.

Example:

// assertion will pass 
assertThat(new HashMap()).isEmpty(); 
// assertion will fail 
Map<String, String> map = new HashMap(); 
map.put("key", "value"); 
assertThat(map).isEmpty();

[中]验证映射是否为空。
例子:

// assertion will pass 
assertThat(new HashMap()).isEmpty(); 
// assertion will fail 
Map<String, String> map = new HashMap(); 
map.put("key", "value"); 
assertThat(map).isEmpty();

代码示例

代码示例来源:origin: hidroh/materialistic

@Test
public void testSyncEnabledCached() throws IOException {
  HackerNewsItem hnItem = mock(HackerNewsItem.class);
  Call<HackerNewsItem> call = mock(Call.class);
  when(call.execute()).thenReturn(Response.success(hnItem));
  when(TestRestServiceFactory.hnRestService.cachedItem(any())).thenReturn(call);
  syncScheduler.scheduleSync(service, "1");
  adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
  // cache hit, should not try network or defer
  verify(TestRestServiceFactory.hnRestService).cachedItem(any());
  verify(TestRestServiceFactory.hnRestService, never()).networkItem(any());
  assertThat(syncPreferences.getAll()).isEmpty();
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testSyncEnabledWifi() throws IOException {
  Call<HackerNewsItem> call = mock(Call.class);
  when(call.execute()).thenThrow(IOException.class);
  when(TestRestServiceFactory.hnRestService.cachedItem(any())).thenReturn(call);
  when(TestRestServiceFactory.hnRestService.networkItem(any())).thenReturn(call);
  syncScheduler.scheduleSync(service, "1");
  adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
  // should try cache before network
  verify(TestRestServiceFactory.hnRestService).cachedItem(any());
  verify(TestRestServiceFactory.hnRestService).networkItem(any());
  assertThat(syncPreferences.getAll()).isEmpty();
  // on network response should try children
  verify(call).enqueue(callbackCapture.capture());
  HackerNewsItem item = mock(HackerNewsItem.class);
  when(item.getKids()).thenReturn(new long[]{2L, 3L});
  callbackCapture.getValue().onResponse(null, Response.success(item));
  verify(TestRestServiceFactory.hnRestService, times(3)).cachedItem(any());
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testSyncEnabledAnyConnection() throws IOException {
  Call<HackerNewsItem> call = mock(Call.class);
  when(call.execute()).thenThrow(IOException.class);
  when(TestRestServiceFactory.hnRestService.cachedItem(any())).thenReturn(call);
  when(TestRestServiceFactory.hnRestService.networkItem(any())).thenReturn(call);
  PreferenceManager.getDefaultSharedPreferences(service)
      .edit()
      .putString(service.getString(R.string.pref_offline_data),
          service.getString(R.string.offline_data_default))
      .apply();
  setNetworkType(ConnectivityManager.TYPE_MOBILE);
  syncScheduler.scheduleSync(service, "1");
  adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
  // should try cache, then network
  verify(TestRestServiceFactory.hnRestService).cachedItem(any());
  verify(TestRestServiceFactory.hnRestService).networkItem(any());
  assertThat(syncPreferences.getAll()).isEmpty();
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void getAll() {
 expect(cache.getAll(asSet(1))).isEmpty();
 changesOf(0, 1, 0, 0);
 cache.put(1, "a");
 cache.put(2, "b");
 changesOf(0, 0, 2, 0);
 expect(cache.getAll(asSet(1, 2, 3))).containsKeys(1, 2);
 changesOf(2, 1, 0, 0);
}

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

@Test(groups = "short")
 public void should_fail_if_host_is_not_connected() {
  // given a statement with host explicitly set that for which we have no active pool.
  Host host4 = TestUtils.findHost(cluster, 4);
  Statement statement = new SimpleStatement("select * system.local").setHost(host4);

  try {
   // when statement is executed
   session.execute(statement);
   fail("Query should have failed");
  } catch (NoHostAvailableException e) {
   // then the request should fail with a NHAE and no host was tried.
   assertThat(e.getErrors()).isEmpty();
  } finally {
   verifyNoLbpInteractions();
  }
 }
}

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

assertThat(e.getFailuresMap()).hasSize(1).containsValue(0);
} else {
 assertThat(e.getFailuresMap()).isEmpty();

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

assertThat(e.getFailuresMap()).hasSize(1).containsValue(1);
} else {
 assertThat(e.getFailuresMap()).isEmpty();

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

assertThat(function.getSimpleName()).isEqualTo("pi");
assertThat(function.getReturnType()).isEqualTo(DataType.cdouble());
assertThat(function.getArguments()).isEmpty();
assertThat(function.getLanguage()).isEqualTo("java");
assertThat(function.getBody()).isEqualTo("return Math.PI;");

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

assertThat(snapshot.getAllStats()).isEmpty();
LatencyAwarePolicy.Snapshot.Stats stats = snapshot.getStats(retrieveSingleHost(cluster));
assertThat(stats).isNull();

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

assertThat(table.getOptions().getExtensions()).isEmpty(); // default
assertThat(table.getOptions().getMemtableFlushPeriodInMs()).isEqualTo(1000);
assertThat(table.asCQLQuery())
assertThat(table.getOptions().getExtensions()).isEmpty(); // default
assertThat(table.getOptions().getMemtableFlushPeriodInMs()).isEqualTo(1000);
assertThat(table.asCQLQuery())
assertThat(table.getOptions().getMaxIndexInterval()).isEqualTo(2048);
assertThat(table.getOptions().getExtensions()).isEmpty();
assertThat(table.getOptions().getMemtableFlushPeriodInMs()).isEqualTo(1000);
assertThat(table.asCQLQuery())
assertThat(table.getOptions().getMaxIndexInterval()).isNull();
assertThat(table.getOptions().getExtensions()).isEmpty();
assertThat(table.getOptions().getMemtableFlushPeriodInMs()).isEqualTo(1000);
assertThat(table.asCQLQuery())
assertThat(table.getOptions().getMaxIndexInterval()).isNull();
assertThat(table.getOptions().getExtensions()).isEmpty();
assertThat(table.asCQLQuery())
  .contains("read_repair_chance = 0.5")

代码示例来源:origin: segmentio/analytics-android

@Test
public void nullableConcurrentHashMapPutAllIgnoresNulls() throws Exception {
 Map<String, String> values = new LinkedHashMap<>();
 values.put(null, null);
 values.put("foo", null);
 values.put(null, "bar");
 Map<String, String> map = new Utils.NullableConcurrentHashMap<>();
 map.putAll(values);
 assertThat(map).isEmpty();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void nullableConcurrentHashMapPutIgnoresNulls() throws Exception {
 Map<String, String> map = new Utils.NullableConcurrentHashMap<>();
 map.put(null, null);
 map.put("foo", null);
 map.put(null, "bar");
 assertThat(map).isEmpty();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void emptyMap() throws Exception {
 assertThat(valueMap).hasSize(0).isEmpty();
}

代码示例来源:origin: segmentio/analytics-android

@Test
public void toStringMap() {
 assertThat(valueMap.toStringMap()).isEmpty();
 valueMap.put("foo", "bar");
 assertThat(valueMap.toStringMap()) //
   .isEqualTo(new ImmutableMap.Builder<String, Object>().put("foo", "bar").build());
}

代码示例来源:origin: drapostolos/type-parser

@Test
public void canParseToEmptyMap() throws Exception {
  GenericType<Map<String, String>> type = new GenericType<Map<String, String>>() {};
  assertThat(parser.parse("null", type))
      .isInstanceOf(Map.class)
      .isEmpty();
}

代码示例来源:origin: segmentio/analytics-android

@Test
 public void createEmptySnapshot() throws IOException {
  StatsSnapshot snapshot = stats.createSnapshot();

  assertThat(snapshot.timestamp).isNotZero();
  assertThat(snapshot.flushCount).isZero();
  assertThat(snapshot.flushEventCount).isZero();
  assertThat(snapshot.integrationOperationCount).isZero();
  assertThat(snapshot.integrationOperationDuration).isZero();
  assertThat(snapshot.integrationOperationAverageDuration).isZero();
  assertThat(snapshot.integrationOperationDurationByIntegration).isEmpty();
 }
}

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

public void testNotPresentWhenDeleting() throws Exception {
 for (String regionId : regions) {
   DeleteStaticLargeObjectResponse resp = getApi().getStaticLargeObjectApi(regionId, defaultContainerName).delete(UUID.randomUUID().toString());
   assertThat(resp.status()).isEqualTo("200 OK");
   assertThat(resp.deleted()).isZero();
   assertThat(resp.notFound()).isEqualTo(1);
   assertThat(resp.errors()).isEmpty();
 }
}

代码示例来源:origin: TNG/junit-dataprovider

@Test
public void testExplodeTestMethodsUseDataProviderShouldReturnMultipleDataProviderFrameworkMethodIfDataConverterReturnsMultipleRows()
    throws Throwable {
  // Given:
  List<Object[]> dataConverterResult = listOfArrays(new Object[] { 11, "22", 33L }, new Object[] { 44, "55", 66L },
      new Object[] { 77, "88", 99L });
  doReturn(dataConverterResult).when(dataConverter).convert(any(), any(Boolean.class), any(Class[].class), any(DataProvider.class));
  doReturn(dataProvider).when(dataProviderMethod).getAnnotation(DataProvider.class);
  doReturn("%c").when(dataProvider).format();
  doReturn(false).when(dataProvider).cache();
  // When:
  List<FrameworkMethod> result = underTest.explodeTestMethod(testMethod, dataProviderMethod);
  // Then:
  assertThat(TestGenerator.dataProviderDataCache).isEmpty();
  assertDataProviderFrameworkMethods(result, dataConverterResult, "%c");
  verify(dataProviderMethod).invokeExplosively(null);
}

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

protected void assertDelete(String regionId, String containerName, String name) {
 DeleteStaticLargeObjectResponse resp = getApi().getStaticLargeObjectApi(regionId, containerName).delete(name);
 assertThat(resp.status()).isEqualTo("200 OK");
 assertThat(resp.deleted()).isEqualTo(3);
 assertThat(resp.notFound()).isZero();
 assertThat(resp.errors()).isEmpty();
 assertEquals(getApi().getContainerApi(regionId).get(containerName).getObjectCount(), Long.valueOf(0));
}

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

@Test(groups = "short")
 public void should_fail_if_host_is_not_connected() {
  // given a statement with host explicitly set that for which we have no active pool.
  Host host4 = TestUtils.findHost(cluster, 4);
  Statement statement = new SimpleStatement("select * system.local").setHost(host4);

  try {
   // when statement is executed
   session.execute(statement);
   fail("Query should have failed");
  } catch (NoHostAvailableException e) {
   // then the request should fail with a NHAE and no host was tried.
   assertThat(e.getErrors()).isEmpty();
  } finally {
   verifyNoLbpInteractions();
  }
 }
}

相关文章