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


Java Example.of方法代码示例

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


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

示例1: testSingle

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Test
public void testSingle() {
	// tag::example-mono[]
	Employee e = new Employee();
	e.setFirstName("Bilbo");
	Example<Employee> example = Example.of(e);
	// end::example-mono[]

	// tag::query-mono[]
	Mono<Employee> singleEmployee = repository.findOne(example);
	// end::query-mono[]

	StepVerifier.create(singleEmployee)
		.expectNextMatches(employee -> {
			assertThat(employee).hasNoNullFieldsOrProperties();
			assertThat(employee.getFirstName()).isEqualTo("Bilbo");
			assertThat(employee.getLastName()).isEqualTo("Baggins");
			assertThat(employee.getRole()).isEqualTo("burglar");
			return true;
		})
		.expectComplete()
		.verify();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:24,代码来源:QueryTests.java

示例2: testSingleWithTemplate

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Test
public void testSingleWithTemplate() {
	// tag::mono-template[]
	Employee e = new Employee();
	e.setFirstName("Bilbo");
	Example<Employee> example = Example.of(e);

	Mono<Employee> singleEmployee = operations.findOne(
		new Query(byExample(example)), Employee.class);
	// end::mono-template[]

	StepVerifier.create(singleEmployee)
		.expectNextMatches(employee -> {
			assertThat(employee).hasNoNullFieldsOrProperties();
			assertThat(employee.getFirstName()).isEqualTo("Bilbo");
			assertThat(employee.getLastName()).isEqualTo("Baggins");
			assertThat(employee.getRole()).isEqualTo("burglar");
			return true;
		})
		.expectComplete()
		.verify();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:23,代码来源:QueryTests.java

示例3: substringMatching

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void substringMatching() {

	Example<Person> example = Example.of(new Person("er", null, null), matching().//
			withStringMatcher(StringMatcher.ENDING));

	assertThat(repository.findAll(example), hasItems(skyler, walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例4: testFindByFoodNameWithExampleMatchers

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Test
public void testFindByFoodNameWithExampleMatchers(){
	ExampleMatcher matcher = ExampleMatcher.matching()
			.withIgnorePaths("id")
			.withIgnorePaths("transactionDate");
	Example<Eats> example = Example.of(eat, matcher);
	List<Eats> response =  eatsRepository.findByFoodName(testFood);
	Eats responseExample = Example.of(response.get(0), matcher).getProbe();
	log.info("response: " + responseExample.toString());
	log.info("repo: " + eatsRepository.findOne(example));
	assert(eatsRepository.findOne(example).equals(responseExample));
}
 
开发者ID:KobePig,项目名称:NutriBuddi,代码行数:13,代码来源:EatsRepositoryTest.java

示例5: testMultiple

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Test
public void testMultiple() {
	// tag::example-flux[]
	Employee e = new Employee();
	e.setLastName("baggins"); // Lowercase lastName

	ExampleMatcher matcher = ExampleMatcher.matching()
		.withIgnoreCase()
		.withMatcher("lastName", startsWith())
		.withIncludeNullValues();

	Example<Employee> example = Example.of(e, matcher);
	// end::example-flux[]

	// tag::query-flux[]
	Flux<Employee> multipleEmployees = repository.findAll(example);
	// end::query-flux[]

	StepVerifier.create(multipleEmployees.collectList())
		.expectNextMatches(employees -> {
			assertThat(employees).hasSize(2);
			assertThat(employees).extracting("firstName")
				.contains("Frodo", "Bilbo");
			return true;
		})
		.expectComplete()
		.verify();
}
 
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:29,代码来源:QueryTests.java

示例6: matchStartingStringsIgnoreCase

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void matchStartingStringsIgnoreCase() {

	Example<User> example = Example.of(new User("Walter", "WHITE", null),
			matching().//
					withIgnorePaths("age").//
					withMatcher("firstname", startsWith()).//
					withMatcher("lastname", ignoreCase()));

	assertThat(repository.findAll(example), hasItems(flynn, walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:UserRepositoryIntegrationTests.java

示例7: matchStartingStringsIgnoreCase

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void matchStartingStringsIgnoreCase() {

	Example<Person> example = Example.of(new Person("Walter", "WHITE", null),
			matching().//
					withIgnorePaths("age").//
					withMatcher("firstname", startsWith()).//
					withMatcher("lastname", ignoreCase()));

	assertThat(repository.findAll(example), hasItems(flynn, walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:UserRepositoryIntegrationTests.java

示例8: findByName

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * 方法名 : findByName
 * 功 能 : TODO(这里用一句话描述这个方法的作用)
 * 参 数 : @param userName
 * 参 数 : @return
 * 参 考 : @see
 * tk.ainiyue.danyuan.application.user.userbase.service.SysUserBaseService#findByName(java.lang.String)
 * 作 者 : Administrator
 */

@Override
public SysUserBaseInfo findByName(String userName) {
	SysUserBaseInfo info = new SysUserBaseInfo();
	info.setUserName(userName);
	Example<SysUserBaseInfo> example = Example.of(info);
	SysUserBaseInfo sourceCodes = sysUserBaseDao.findOne(example);
	return sourceCodes;
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:19,代码来源:SysUserBaseServiceImpl.java

示例9: configuringMatchersUsingLambdas

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void configuringMatchersUsingLambdas() {

	Example<Person> example = Example.of(new Person("Walter", "WHITE", null),
			matching().//
					withIgnorePaths("age"). //
					withMatcher("firstname", matcher -> matcher.startsWith()). //
					withMatcher("lastname", matcher -> matcher.ignoreCase()));

	assertThat(operations.find(query(byExample(example)), Person.class), hasItems(flynn, walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:MongoOperationsIntegrationTests.java

示例10: substringMatching

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void substringMatching() {

	Example<User> example = Example.of(new User("er", null, null), matching().//
			withStringMatcher(StringMatcher.ENDING));

	assertThat(repository.findAll(example), hasItems(skyler, walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例11: countBySimpleExample

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void countBySimpleExample() {

	Example<User> example = Example.of(new User(null, "White", null));

	assertThat(repository.count(example), is(3L));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:11,代码来源:UserRepositoryIntegrationTests.java

示例12: ignorePropertiesAndMatchByAge

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void ignorePropertiesAndMatchByAge() {

	Example<User> example = Example.of(flynn, matching().//
			withIgnorePaths("firstname", "lastname"));

	assertThat(repository.findOne(example), is(flynn));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例13: valueTransformer

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
/**
 * @see #153
 */
@Test
public void valueTransformer() {

	Example<User> example = Example.of(new User(null, "White", 99), matching(). //
			withMatcher("age", matcher -> matcher.transform(value -> Integer.valueOf(50))));

	assertThat(repository.findAll(example), hasItems(walter));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:12,代码来源:UserRepositoryIntegrationTests.java

示例14: findAllBySysColumnInfo

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Override
public List<SysColumnInfo> findAllBySysColumnInfo(SysColumnInfo info) {
	Example<SysColumnInfo> example = Example.of(info);
	return sysColumnDao.findAll(example);
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:6,代码来源:SysColumnServiceImpl.java

示例15: findAll

import org.springframework.data.domain.Example; //导入方法依赖的package包/类
@Override
public List<SysTableInfo> findAll(SysTableInfo sysTableInfo) {
	Example<SysTableInfo> example = Example.of(sysTableInfo);
	return sysTableDao.findAll(example);
}
 
开发者ID:514840279,项目名称:danyuan-application,代码行数:6,代码来源:SysTableServiceImpl.java


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