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


Java Assert.assertThat方法代码示例

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


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

示例1: create

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void create(@Mocked ConsumerSchemaFactory consumerSchemaFactory,
    @Mocked SchemaListenerManager schemaListenerManager) {
  String microserviceName = "app:ms";
  String microserviceId = "id";
  Microservice microservice = new Microservice();
  microservice.setVersion("1.0.0");

  new Expectations(RegistryUtils.class) {
    {
      RegistryUtils.getMicroservice(microserviceId);
      result = microservice;
    }
  };
  CseContext.getInstance().setConsumerSchemaFactory(consumerSchemaFactory);
  CseContext.getInstance().setSchemaListenerManager(schemaListenerManager);

  MicroserviceVersionMetaFactory factory = new MicroserviceVersionMetaFactory();
  MicroserviceVersion microserviceVersion = factory.create(microserviceName, microserviceId);
  Assert.assertThat(microserviceVersion, Matchers.instanceOf(MicroserviceVersionMeta.class));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:22,代码来源:TestMicroserviceVersionMetaFactory.java

示例2: testSetPredicate

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testSetPredicate() throws Exception {
    PredicateBasedRuleSupport support = new PredicateBasedRuleSupport();
    Assert.assertThat(support.getPredicate(), is(nullValue()));
    support.setPredicate(predicate);
    Assert.assertThat(support.getPredicate(), is(predicate));
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:8,代码来源:PredicateBasedRuleSupportTest.java

示例3: testGetParameterValuesNormal

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testGetParameterValuesNormal() {
  Map<String, List<String>> queryParams = new HashMap<>();
  queryParams.put("name", Arrays.asList("value"));

  HttpServletRequest request = new CommonToHttpServletRequest(null, queryParams, null, null, false);
  Assert.assertThat(request.getParameterValues("name"), Matchers.arrayContaining("value"));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:9,代码来源:TestCommonToHttpServletRequest.java

示例4: testGenerate_Number_WithRightAddon

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testGenerate_Number_WithRightAddon() throws JsonProcessingException {
	UiForm ui = UiFormSchemaGenerator.get().generate(NumberFormRight.class);
	String json = new ObjectMapper().writeValueAsString(ui);
	//Assert.assertThat(json, hasJsonPath("$.schema.properties.number.title",equalTo("Number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')]",hasSize(1)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].description",hasItem("This is a number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].placeholder",hasItem("Number of children")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].validationMessage",hasItem("this is a validation msg")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].type",hasItem("number")));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].notitle",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].readonly",hasItem(true)));
	Assert.assertThat(json, hasJsonPath("$.form[?(@.key=='number')].fieldAddonRight",hasItem("@")));

}
 
开发者ID:JsonSchema-JavaUI,项目名称:sf-java-ui,代码行数:16,代码来源:NumberFormTest.java

示例5: testAttributesBasic

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testAttributesBasic() {
	Task task = createTask(2, "sample task");

	Document document = mapper.toDocument(toResponse(task), createAdapter(Task.class));
	Resource resource = document.getSingleData().get();
	Assert.assertEquals("2", resource.getId());
	Assert.assertEquals("tasks", resource.getType());
	Assert.assertEquals("sample task", resource.getAttributes().get("name").asText());
	Assert.assertThat(resource.getAttributes().get("writeOnlyValue"), CoreMatchers.nullValue());
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:12,代码来源:DocumentMapperTest.java

示例6: fail_on_get_property

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void fail_on_get_property() throws Exception {
    when(message.getPropertyNames()).thenReturn(Collections.enumeration(asList("1", "2", "3")));
    when(message.getStringProperty("1")).thenReturn("1");
    when(message.getStringProperty("2")).thenThrow(JMSException.class);
    propagator.copyFromMessage(message);
    verify(message).getStringProperty(eq("1"));
    verify(message).getStringProperty(eq("2"));
    verify(message, never()).getStringProperty(eq("3"));
    Assert.assertThat(current().containsKey("1"), is(true));
    Assert.assertThat(current().entrySet().size(), is(1));
}
 
开发者ID:enadim,项目名称:spring-cloud-ribbon-extensions,代码行数:13,代码来源:AbstractPreservesMessagePropertiesTest.java

示例7: testPutSelfBasePathIfAbsent_WithUrlPrefix

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testPutSelfBasePathIfAbsent_WithUrlPrefix() {
  System.setProperty(Const.URL_PREFIX, "/root/rest");
  microservice.setPaths(new ArrayList<>());

  loader.putSelfBasePathIfAbsent("perfClient", "/test");

  Assert.assertThat(microservice.getPaths().size(), Matchers.is(1));
  Assert.assertThat(microservice.getPaths().get(0).getPath(), Matchers.is("/root/rest/test"));

  System.clearProperty(Const.URL_PREFIX);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:13,代码来源:TestDynamicSchemaLoader.java

示例8: reenqueue_should_return_false_when_no_update

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void reenqueue_should_return_false_when_no_update() throws Exception {
    QueueLocation location = generateUniqueLocation();
    Boolean reenqueueResult = executeInTransaction(() ->
            queueActorDao.reenqueue(location, "...", Duration.ofHours(1L)));
    Assert.assertThat(reenqueueResult, equalTo(false));
}
 
开发者ID:yandex-money,项目名称:db-queue,代码行数:8,代码来源:QueueActorDaoTest.java

示例9: testAttribute

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testAttribute() {
  String key = "a1";
  String value = "abc";
  request.setAttribute(key, value);
  Assert.assertSame(value, request.getAttribute(key));
  Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key));

  request.setAttribute("a2", "v");
  Assert.assertThat(Collections.list(request.getAttributeNames()), Matchers.contains(key, "a2"));

  request.removeAttribute(key);
  Assert.assertNull(request.getAttribute(key));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestAbstractHttpServletRequest.java

示例10: shouldGetCustomMapClaim

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void shouldGetCustomMapClaim() throws Exception {
    String token = "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjp7InN0cmluZyI6InZhbHVlIiwibnVtYmVyIjoxLCJib29sZWFuIjp0cnVlfX0.-8aIaXd2-rp1lLuDEQmCeisCBX9X_zbqdPn2llGxNoc";
    JWT jwt = JWT.require(Algorithm.HMAC256("secret")).build();
    DecodedJWT decodedJWT = jwt.decode(token);
    Assert.assertThat(decodedJWT, is(notNullValue()));
    Map<String, Object> map = decodedJWT.getClaim("name").asMap();
    Assert.assertThat(map, hasEntry("string", (Object) "value"));
    Assert.assertThat(map, hasEntry("number", (Object) 1));
    Assert.assertThat(map, hasEntry("boolean", (Object) true));
}
 
开发者ID:GJWT,项目名称:javaOIDCMsg,代码行数:12,代码来源:JWTDecoderTest.java

示例11: testGetHeaderNames

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testGetHeaderNames() {
  MultiMap headers = MultiMap.caseInsensitiveMultiMap();
  headers.add("name", "value");
  new Expectations() {
    {
      vertxRequest.headers();
      result = headers;
    }
  };

  Assert.assertThat(Collections.list(request.getHeaderNames()), Matchers.contains("name"));

}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:15,代码来源:TestVertxServerRequestToHttpServletRequest.java

示例12: testIgnored

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testIgnored() {
    // given
    Wrapper wrapper = new Wrapper();

    // when
    Integer minMax = postprocess(wrapper, "ignored", Integer.class);

    // then
    Assert.assertThat(minMax, CoreMatchers.is(0));
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:12,代码来源:MinMaxAnnotationPostProcessorTest.java

示例13: testNoAnnotation

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testNoAnnotation() {
    // given
    Wrapper wrapper = new Wrapper();

    // when
    Float retVal = postprocess(wrapper, "aFloat", Float.class);

    // then
    Assert.assertThat(retVal, is(0f));
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:12,代码来源:DigitsAnnotationPostProcessorTest.java

示例14: testClone

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testClone()
{
    TopicSubscription topic = new TopicSubscription(TOPIC_FILTER, MqttQualityOfService.QOS_0);
    TopicSubscription clone = topic.clone();
    Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
    Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
    topic.setSubscribed(true);
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.not(clone.isSubscribed())));
    clone = topic.clone();
    Assert.assertEquals(topic.getTopicFilter(), clone.getTopicFilter());
    Assert.assertEquals(topic.getQualityOfService(), clone.getQualityOfService());
    Assert.assertThat(topic.isSubscribed(), Is.is(CoreMatchers.equalTo(clone.isSubscribed())));
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:16,代码来源:TopicSubscriptionTest.java

示例15: testMinMaxOnStringAnnotation

import org.junit.Assert; //导入方法依赖的package包/类
@Test
public void testMinMaxOnStringAnnotation() {
    // given
    Wrapper wrapper = new Wrapper();
    wrapper.string = "abcdefghijklmon.......";

    // when
    String minMax = postprocess(wrapper, "string", String.class);

    // then
    Assert.assertThat(minMax.length(), OrderingComparison.greaterThan(2));
    Assert.assertThat(minMax.length(), OrderingComparison.lessThanOrEqualTo(5));
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:14,代码来源:MinMaxAnnotationPostProcessorTest.java


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