当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newHashMap方法代码示例

本文整理汇总了Java中org.assertj.core.util.Maps.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMap方法的具体用法?Java Maps.newHashMap怎么用?Java Maps.newHashMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.assertj.core.util.Maps的用法示例。


在下文中一共展示了Maps.newHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testMap

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
public void testMap() {
    Map<String, Object> foo = Maps.newHashMap();
    foo.put("A", 1);
    foo.put("B", 2);
    foo.put("C", 3);

    // 断言 map 不为空 size
    assertThat(foo).isNotEmpty().hasSize(3);
    // 断言 map 包含元素
    assertThat(foo).contains(entry("A", 1), entry("B", 2));
    // 断言 map 包含key
    assertThat(foo).containsKeys("A", "B", "C");
    // 断言 map 包含value
    assertThat(foo).containsValue(3);
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:17,代码来源:AssertjTest.java

示例2: setup

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
/** 
 * Configured the actions of 'created', 'updated', and 'deleted' for Book changes 
 * and which topic the book change events are published to
 */
@Before
public void setup(){
	
	config = new StateChangeConfiguration();
	
	final Map<String, String> eventMap = Maps.newHashMap();
	eventMap.put("Created", TOPIC);
	eventMap.put("Deleted", TOPIC);
	eventMap.put("Updated", TOPIC);
	
	final Map<String, Map<String, String>> modelMap = Maps.newHashMap();
	modelMap.put(Book.class.getName(), eventMap);
	config.setEvents(modelMap);
	changePublisher = new StateChangePublisher(config, this.publisher);
}
 
开发者ID:shagwood,项目名称:micro-genie,代码行数:20,代码来源:StateChangePublisherTest.java

示例3: itShouldHandleFullDrainageForFixedLineItemDiscounts

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
/**
 * Verifies that there is no amounts remaining after all items has been removed, even if there was a fixed line item
 * discount
 */
public void itShouldHandleFullDrainageForFixedLineItemDiscounts() {
    final Object id1 = UUID.randomUUID();
    final Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> cart = createCart(
        new TestItem(id1, "Main thing", 1L, 30f, BigDecimal.valueOf(1L), new TestDiscount(10L, null, BigDecimal.ONE))
    );
    final long originalValue = cart.getValue();
    final Map<Object, BigDecimal> currentRefund = Maps.newHashMap(id1, BigDecimal.ONE.negate());
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> alterationCart = cart
        .createAlterationCart(null, currentRefund);
    final long alterationValue = alterationCart.getValue();
    assertEquals(originalValue, -1 * alterationValue);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:18,代码来源:AlterationTest.java

示例4: itShouldHandleFullDrainageForPercentageLineItemDiscounts

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
/**
 * Verifies that there is no amounts remaining after all items has been removed, even if there was a percentage line
 * item discount
 */
public void itShouldHandleFullDrainageForPercentageLineItemDiscounts() {
    final Object id = UUID.randomUUID();
    final Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> cart = createCart(
        new TestItem(id, "Main thing", 1L, 30f, BigDecimal.valueOf(1L), new TestDiscount(null, 50d, BigDecimal.ONE))
    );
    final long originalValue = cart.getValue();
    final Map<Object, BigDecimal> currentRefund = Maps.newHashMap(id, BigDecimal.ONE.negate());
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> alterationCart2 = cart
        .createAlterationCart(null, currentRefund);
    final long alterationValue2 = alterationCart2.getValue();
    assertEquals(originalValue, -1 * alterationValue2);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:18,代码来源:AlterationTest.java

示例5: itShouldHandleFullDrainageForFixedCartWideDiscounts

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
/**
 * Verifies that there is no amounts remaining after all items has been removed, even if there was a fixed cart wide
 * discount
 */
public void itShouldHandleFullDrainageForFixedCartWideDiscounts() {
    final Object id = UUID.randomUUID();
    final TestDiscount discount = new TestDiscount(10L, null, BigDecimal.ONE);
    final Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> cart
        = new Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge>(
            Arrays.asList(createItem(id, 10L, 30f, BigDecimal.valueOf(2L))),
            Arrays.asList(discount),
            null
        );
    final long originalValue = cart.getValue();
    final Map<Object, BigDecimal> firstAlteration = Maps.newHashMap(id, BigDecimal.ONE.negate());
    final Map<Object, BigDecimal> currentRefund = Maps.newHashMap(id, BigDecimal.ONE.negate());
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> firstAlterationCart = cart
        .createAlterationCart(null, firstAlteration);
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> secondAlterationCart = cart
        .createAlterationCart(Arrays.asList(firstAlteration), currentRefund);
    final long firstAlterationValue = firstAlterationCart.getValue();
    final long secondalterationValue = secondAlterationCart.getValue();
    assertEquals(originalValue, -1 * (firstAlterationValue + secondalterationValue));
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:26,代码来源:AlterationTest.java

示例6: itShouldHandleFullDrainageForPercentageCartWideDiscounts

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
/**
 * Verifies that there is no amounts remaining after all items has been removed, even if there was a percentage cart
 * wide discount
 */
public void itShouldHandleFullDrainageForPercentageCartWideDiscounts() {
    final Object id = UUID.randomUUID();
    final TestDiscount discount = new TestDiscount(null, 20d, BigDecimal.ONE);
    final Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> cart
        = new Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge>(
            Arrays.asList(createItem(id, 10L, 30f, BigDecimal.valueOf(2L))),
            Arrays.asList(discount),
            null
        );
    final long originalValue = cart.getValue();
    final Map<Object, BigDecimal> firstAlteration = Maps.newHashMap(id, BigDecimal.ONE.negate());
    final Map<Object, BigDecimal> currentRefund = Maps.newHashMap(id, BigDecimal.ONE.negate());
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> firstAlterationCart = cart
        .createAlterationCart(null, firstAlteration);
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> secondAlterationCart = cart
        .createAlterationCart(Arrays.asList(firstAlteration), currentRefund);
    final long firstAlterationValue = firstAlterationCart.getValue();
    final long secondalterationValue = secondAlterationCart.getValue();
    assertEquals(originalValue, -1 * (firstAlterationValue + secondalterationValue));
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:26,代码来源:AlterationTest.java

示例7: itShouldCalculateCorrectCartWideDiscountValueAfterAlteration

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
public void itShouldCalculateCorrectCartWideDiscountValueAfterAlteration() {
    final Object id1 = UUID.randomUUID();
    final Object id2 = UUID.randomUUID();
    final Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> cart
        = new Cart<TestItem, TestDiscount, TestDiscount, TestServiceCharge>(
            Arrays.asList(
                new TestItem(id1, "banan", 1000L, 30f, BigDecimal.valueOf(2L), new TestDiscount(200L, null, BigDecimal.ONE)),
                new TestItem(id2, "äpple", 1000L, 30f, BigDecimal.valueOf(1L), null)
            ),
            Arrays.asList(new TestDiscount(600L, null, BigDecimal.ONE)),
            null
        );
    final Map<Object, BigDecimal> currentAlteration = Maps.newHashMap(id1, BigDecimal.ONE.negate());
    final AlterationCart<TestItem, TestDiscount, TestDiscount, TestServiceCharge> firstAlterationCart = cart
        .createAlterationCart(null, currentAlteration);
    final long originalCartWideDiscount = cart.getCartWideDiscountValue();
    assertEquals(600L, originalCartWideDiscount);
    final long alterationCartWideDiscount = firstAlterationCart.getCartWideDiscountValue();
    assertEquals(-193L, alterationCartWideDiscount);
}
 
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:22,代码来源:AlterationTest.java

示例8: testSimpleFrameWarningsAndCustomPayload

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
public void testSimpleFrameWarningsAndCustomPayload() throws Exception {
  UUID uuid = UUID.fromString("ce565629-e8e4-4f93-bdd4-9414b7d9d342");
  // 0x0708 == Bwg= base64 encoded
  Map<String, ByteBuffer> customPayload =
      Maps.newHashMap("custom", ByteBuffer.wrap(new byte[] {0x7, 0x8}));
  Frame frame =
      new Frame(
          5,
          true,
          10,
          true,
          uuid,
          customPayload,
          Lists.newArrayList("Something went wrong", "Fix me!"),
          com.datastax.oss.protocol.internal.request.Options.INSTANCE);

  String json = writer.writeValueAsString(frame);
  assertThat(json)
      .isEqualTo(
          "{\n"
              + "  \"protocol_version\" : 5,\n"
              + "  \"beta\" : true,\n"
              + "  \"stream_id\" : 10,\n"
              + "  \"tracing_id\" : \"ce565629-e8e4-4f93-bdd4-9414b7d9d342\",\n"
              + "  \"custom_payload\" : {\n"
              + "    \"custom\" : \"Bwg=\"\n"
              + "  },\n"
              + "  \"warnings\" : [ \"Something went wrong\", \"Fix me!\" ],\n"
              + "  \"message\" : {\n"
              + "    \"type\" : \"OPTIONS\",\n"
              + "    \"opcode\" : 5,\n"
              + "    \"is_response\" : false\n"
              + "  }\n"
              + "}");
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:37,代码来源:FrameSerializerTest.java

示例9: testBuilder_setAdditionalProperties_nullKey

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
public void testBuilder_setAdditionalProperties_nullKey() {
    final Map<String, byte[]> mapWithNullKey = Maps.newHashMap(null, new byte[0]);
    assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
        @Override
        public void call() throws Throwable {
            mBuilder.setAdditionalProperties(mapWithNullKey);
        }
    }).isInstanceOf(IllegalArgumentException.class);
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:11,代码来源:AdditionalPropertiesTest.java

示例10: testBuild_setAdditionalProperty_nullValue

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Test
public void testBuild_setAdditionalProperty_nullValue() {
    final Map<String, byte[]> mapWithNullValue = Maps.newHashMap("a", null);


    assertThatThrownBy(new ThrowableAssert.ThrowingCallable() {
        @Override
        public void call() throws Throwable {
            mBuilder.setAdditionalProperties(mapWithNullValue);
        }
    }).isInstanceOf(IllegalArgumentException.class);
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:13,代码来源:AdditionalPropertiesTest.java

示例11: run

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
@Override
public void run(String... args) throws Exception {
    Map<String,JobParameter> params = Maps.newHashMap();
    params.put("message", new JobParameter("przodownik -> batch -> first -> example"));
    JobParameters jobParameters = new JobParameters(params);
    jobLauncher.run(firstJob, jobParameters);
    
}
 
开发者ID:przodownikR1,项目名称:springBatchBootJavaConfigkata,代码行数:9,代码来源:BatchBootConfig.java

示例12: checkRegion

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
/**
 * Invokes checkRegion with the specified configuration.
 *
 * @param region the region name
 */
protected void checkRegion(String region) {
  Map<String, String> configMap = Maps.newHashMap();
  configMap.put(REGION.unwrap().getConfigKey(), region);
  Configured configuration = new SimpleConfiguration(configMap);
  validator.checkRegion(configuration, accumulator, localizationContext);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:12,代码来源:GoogleComputeProviderConfigurationValidatorTest.java

示例13: checkZone

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
/**
 * Invokes checkZone with the specified configuration.
 *
 * @param zone the zone name
 */
protected void checkZone(String zone) {
  Map<String, String> configMap = Maps.newHashMap();
  configMap.put(ZONE.unwrap().getConfigKey(), zone);
  Configured configuration = new SimpleConfiguration(configMap);
  validator.checkZone(configuration, accumulator, localizationContext);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:12,代码来源:GoogleComputeInstanceTemplateConfigurationValidatorTest.java

示例14: checkImage

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
/**
 * Invokes checkImage with the specified configuration.
 *
 * @param image the image name
 */
protected void checkImage(String image) {
  Map<String, String> configMap = Maps.newHashMap();
  configMap.put(IMAGE.unwrap().getConfigKey(), image);
  Configured configuration = new SimpleConfiguration(configMap);
  validator.checkImage(configuration, accumulator, localizationContext);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:12,代码来源:GoogleComputeInstanceTemplateConfigurationValidatorTest.java

示例15: checkBootDiskType

import org.assertj.core.util.Maps; //导入方法依赖的package包/类
/**
 * Invokes checkBootDiskType with the specified configuration.
 *
 * @param bootDiskType the type of boot disk
 */
protected void checkBootDiskType(String bootDiskType) {
  Map<String, String> configMap = Maps.newHashMap();
  configMap.put(BOOT_DISK_TYPE.unwrap().getConfigKey(), bootDiskType);
  Configured configuration = new SimpleConfiguration(configMap);
  validator.checkBootDiskType(configuration, accumulator, localizationContext);
}
 
开发者ID:cloudera,项目名称:director-google-plugin,代码行数:12,代码来源:GoogleComputeInstanceTemplateConfigurationValidatorTest.java


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