• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IsAnything类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.hamcrest.core.IsAnything的典型用法代码示例。如果您正苦于以下问题:Java IsAnything类的具体用法?Java IsAnything怎么用?Java IsAnything使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IsAnything类属于org.hamcrest.core包,在下文中一共展示了IsAnything类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: answersConditionally

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * MkContainer can return certain answers for matching conditions.
 * @throws Exception If something goes wrong inside.
 */
@Test
public void answersConditionally() throws Exception {
    final String match = "matching";
    final String mismatch = "not matching";
    try (final MkContainer container = new MkGrizzlyContainer()) {
        container.next(
            new MkAnswer.Simple(mismatch),
            Matchers.not(new IsAnything<MkQuery>())
        ).next(new MkAnswer.Simple(match), new IsAnything<MkQuery>())
            .start();
        new JdkRequest(container.home())
            .through(VerboseWire.class)
            .fetch().as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK)
            .assertBody(
                Matchers.allOf(
                    Matchers.is(match),
                    Matchers.not(mismatch)
                )
            );
    }
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:27,代码来源:MkContainerTest.java


示例2: canAnswerMultipleTimes

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * MkContainer can answer multiple times for matching requests.
 * @throws Exception If something goes wrong inside
 */
@Test
public void canAnswerMultipleTimes() throws Exception {
    final String body = "multiple";
    final int times = 5;
    try (final MkContainer container = new MkGrizzlyContainer()) {
        container.next(
            new MkAnswer.Simple(body),
            new IsAnything<MkQuery>(),
            times
        ).start();
        final Request req = new JdkRequest(container.home())
            .through(VerboseWire.class);
        for (int idx = 0; idx < times; idx += 1) {
            req.fetch().as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .assertBody(Matchers.is(body));
        }
    }
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:24,代码来源:MkContainerTest.java


示例3: prioritizesMatchingAnswers

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * MkContainer can prioritize multiple matching answers by using the
 * first matching request.
 * @throws Exception If something goes wrong inside.
 */
@Test
public void prioritizesMatchingAnswers() throws Exception {
    final String first = "first";
    final String second = "second";
    try (final MkContainer container = new MkGrizzlyContainer()) {
        container
            .next(new MkAnswer.Simple(first), new IsAnything<MkQuery>())
            .next(new MkAnswer.Simple(second), new IsAnything<MkQuery>())
            .start();
        new JdkRequest(container.home())
            .through(VerboseWire.class)
            .fetch().as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK)
            .assertBody(
                Matchers.allOf(
                    Matchers.is(first),
                    Matchers.not(second)
                )
            );
    }
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:27,代码来源:MkContainerTest.java


示例4: getExtractionResultReturnCorrectEntities

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void getExtractionResultReturnCorrectEntities() {
	// GIVEN
	String fixture1 = "Fixture1";
	Integer fixture2 = 2;


	MappingFixture mappingFixture = new MappingFixture(fixture1, fixture2)
			.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));

	// WHEN
	ExtractionResult extractionResult = mappingFixture.getExtractionResult();

	// THEN
	assertThat(extractionResult.getEntities()).containsOnly(fixture1, fixture2);
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:17,代码来源:TestMappingFixture.java


示例5: testTransform

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void testTransform() throws NoSuchFieldException {
	// GIVEN
	XlsxFileFixture xlsxFileFixture = new XlsxFileFixture("classpath:tests/fixtures/xlsx-fixture.xlsx");
	xlsxFileFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	xlsxFileFixture.setFilter(new Filter() {
		@Override
		public boolean filter(Object entity) {
			return false;
		}
	});

	// WHEN
	ObjectFixture transformedFixture = xlsxFileFixtureTransformer.transform(xlsxFileFixture);

	// THEN
	assertCorrectCartEntry(xlsxFileFixture, transformedFixture);
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:19,代码来源:TestXlsxFileFixtureTransformer.java


示例6: testTransform

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void testTransform() throws NoSuchFieldException {
	// GIVEN
	XmlFileFixture xmlFileFixture = new XmlFileFixture("classpath:tests/fixtures/xml-fixture.xml");
	xmlFileFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	xmlFileFixture.setFilter(new Filter() {
		@Override
		public boolean filter(Object entity) {
			return false;
		}
	});

	// WHEN
	ObjectFixture transformedFixture = xmlFileFixtureTransformer.transform(xmlFileFixture);

	// THEN
	assertCorrectCartEntry(xmlFileFixture, transformedFixture);
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:19,代码来源:TestXmlFileFixtureTransformer.java


示例7: testTransform

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void testTransform() throws NoSuchFieldException {
	// GIVEN
	SpringFixture springFixture = new SpringFixture("classpath:/tests/fixtures/spring-fixture.xml", User.class);
	springFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	springFixture.setFilter(new Filter() {
		@Override
		public boolean filter(Object entity) {
			return false;
		}
	});

	// WHEN
	ObjectFixture transformedFixture = springFixtureTransformer.transform(springFixture);

	// THEN
	assertThat(transformedFixture).isInstanceOf(Fixture.class);

	assertThat(transformedFixture.getObjects()).hasSize(1);
	assertThat(transformedFixture.getObjects().get(0)).isInstanceOf(User.class);
	assertThat(springFixture.getExtractionResult().getEntities()).hasSize(1);

	assertThat(FilterableFixtureProxy.get(transformedFixture).filter("")).isFalse();
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:25,代码来源:TestSpringFixtureTransformer.java


示例8: testTransform

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void testTransform() throws NoSuchFieldException {
	// GIVEN
	XlsFileFixture xlsFileFixture = new XlsFileFixture("classpath:tests/fixtures/xls-fixture.xls");
	xlsFileFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	xlsFileFixture.setFilter(new Filter() {
		@Override
		public boolean filter(Object entity) {
			return false;
		}
	});

	// WHEN
	ObjectFixture transformedFixture = xlsFileFixtureTransformer.transform(xlsFileFixture);

	// THEN
	assertCorrectCartEntry(xlsFileFixture, transformedFixture);
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:19,代码来源:TestXlsFileFixtureTransformer.java


示例9: getExtractionResultReturnCorrectEntities

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void getExtractionResultReturnCorrectEntities() {
	// GIVEN
	generatedFixture //
			.addGenerators( //
					GeneratedFixture.from(new Product()) //
							.addFieldGenerator("id", FieldGenerators.in("1", "2")) //
			) //
			.addExtractorMatcher(ExtractorMatcher.create("name", new IsAnything())) //
			.start();

	// WHEN
	while (generatedFixture.hasNext()) {
		generatedFixture.next();
	}

	// THEN
	assertThat(generatedFixture.getExtractionResult().getEntities()).hasSize(2);
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:20,代码来源:TestGeneratedFixture.java


示例10: getExtractionResultReturnCorrectEntities

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void getExtractionResultReturnCorrectEntities() throws IOException {
	// GIVEN
	File file = folder.newFile("foo.txt");
	FileUtils.writeStringToFile(file, "someContent");

	String filePath = file.getAbsoluteFile().getAbsolutePath();
	FileFixture fileFixture = buildFixture(filePath);
	fileFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	fileFixture.populateExtractionResult(Arrays.<Object>asList("string1", "string2"));

	// WHEN
	ExtractionResult extractionResult = fileFixture.getExtractionResult();

	// THEN
	assertThat(extractionResult.getEntities()).containsOnly("string1", "string2");
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:18,代码来源:TestFileFixture.java


示例11: returnsErrorIfNoMatches

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * MkContainer returns HTTP 500 if no answers match.
 * @throws Exception If something goes wrong inside
 */
@Test(expected = NoSuchElementException.class)
public void returnsErrorIfNoMatches() throws Exception {
    try (final MkContainer container = new MkGrizzlyContainer()) {
        container.next(
            new MkAnswer.Simple("not supposed to match"),
            Matchers.not(new IsAnything<MkQuery>())
        ).start();
        new JdkRequest(container.home())
            .through(VerboseWire.class)
            .fetch().as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_INTERNAL_ERROR);
        container.take();
    }
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:19,代码来源:MkContainerTest.java


示例12: cachesGetRequest

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * LastModifiedCachingWire can cache GET requests.
 * @throws Exception If fails
 */
@Test
public void cachesGetRequest() throws Exception {
    final Map<String, String> headers = Collections.singletonMap(
        HttpHeaders.LAST_MODIFIED,
        "Wed, 15 Nov 1995 04:58:08 GMT"
    );
    final MkContainer container = new MkGrizzlyContainer()
        .next(
            new MkAnswer.Simple(
                HttpURLConnection.HTTP_OK,
                headers.entrySet(),
                LastModifiedCachingWireTest.BODY.getBytes()
            )
        )
        .next(
            new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_MODIFIED),
            new IsAnything<MkQuery>(),
            Tv.TEN
        ).start();
    try {
        final Request req = new JdkRequest(container.home())
            .through(LastModifiedCachingWire.class);
        for (int idx = 0; idx < Tv.TEN; ++idx) {
            req.fetch().as(RestResponse.class)
                .assertStatus(HttpURLConnection.HTTP_OK)
                .assertBody(
                    Matchers.equalTo(LastModifiedCachingWireTest.BODY)
            );
        }
        MatcherAssert.assertThat(
            container.queries(), Matchers.equalTo(Tv.TEN)
        );
    } finally {
        container.stop();
    }
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:41,代码来源:LastModifiedCachingWireTest.java


示例13: functionMatcherOnUpperAndLowerFunctions

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void functionMatcherOnUpperAndLowerFunctions() {
    sqlWithFunctions = "SELECT UPPER(foo), LOWER(bar) FROM MyTable";
    statementWithFunctions = getParseTree(sqlWithFunctions);        
    
    assertThat(statementWithFunctions, hasInQuery(result(upper(new IsAnything<QueryTreeNode>()))));        
    assertThat(statementWithFunctions, hasInQuery(result(upper(column("foo")))));        
    assertThat(statementWithFunctions, hasInQuery(result(lower(column("bar")))));
    
    //no such column
    assertThat(statementWithFunctions, not(hasInQuery(where(lower(column("barry"))))));
}
 
开发者ID:Diio-LLC,项目名称:hamcrest-sql,代码行数:13,代码来源:QueryMatcherTest.java


示例14: getExtractionResultReturnCorrectEntities

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Test
public void getExtractionResultReturnCorrectEntities() {
	// GIVEN
	SpringFixture springFixture = new SpringFixture("context", Arrays.<Class<?>>asList(String.class, Integer.class));
	springFixture.addExtractorMatcher(ExtractorMatcher.create(new IsAnything()));
	springFixture.populateExtractionResult(Arrays.<Object>asList("string1", "string2"));

	// WHEN
	ExtractionResult extractionResult = springFixture.getExtractionResult();

	// THEN
	assertThat(extractionResult.getEntities()).containsOnly("string1", "string2");
}
 
开发者ID:cpollet,项目名称:jixture,代码行数:14,代码来源:TestSpringFixture.java


示例15: getConstraints

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Override
public Matcher<View> getConstraints() {
    return new IsAnything<>();
}
 
开发者ID:vshkl,项目名称:PXLSRT,代码行数:5,代码来源:CameraViewTest.java


示例16: next

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
@Override
public MkContainer next(final MkAnswer answer) {
    return this.next(answer, new IsAnything<MkQuery>());
}
 
开发者ID:jcabi,项目名称:jcabi-http,代码行数:5,代码来源:MkGrizzlyContainer.java


示例17: succeeded

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
public static <T> Matcher<Async<T>> succeeded() {
  return result(new IsAnything<T>());
}
 
开发者ID:JetBrains,项目名称:mapper,代码行数:4,代码来源:AsyncMatchers.java


示例18: failed

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
public static Matcher<Async<?>> failed() {
  return failure(new IsAnything<>());
}
 
开发者ID:JetBrains,项目名称:mapper,代码行数:4,代码来源:AsyncMatchers.java


示例19: cased

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * Syntactic sugar! This version only checks the content of a conditional in a WHEN clause, such as
 * CASE WHEN (my_id=35)
 *
 * For example, assertThat(query, cased(column("my_id").equals(35)));
 */
@Factory
public static Matcher<QueryTreeNode> cased(Matcher<QueryTreeNode> whenMatcher) {
    return new CaseStatementMatcher(whenMatcher, new IsAnything<QueryTreeNode>(), new IsAnything<QueryTreeNode>());
}
 
开发者ID:Diio-LLC,项目名称:hamcrest-sql,代码行数:11,代码来源:CaseStatementMatcher.java


示例20: castedValue

import org.hamcrest.core.IsAnything; //导入依赖的package包/类
/**
 * Syntactic sugar for the case where you are merely trying to match a casted value.
 *
 * For example, assertThat(query, hasInQuery(castedValue(literal("11:23:45"))));
 */
@Factory
public static Matcher<QueryTreeNode> castedValue(Matcher<QueryTreeNode> subMatcher) {
    return new CastMatcher(new IsAnything<TypeId>(), subMatcher);
}
 
开发者ID:Diio-LLC,项目名称:hamcrest-sql,代码行数:10,代码来源:CastMatcher.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RGBColour类代码示例发布时间:2022-05-22
下一篇:
Java ActivationSystemException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap