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


Java IsAnything类代码示例

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


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


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