本文整理汇总了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();
}
示例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();
}
示例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));
}
示例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));
}
示例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();
}
示例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));
}
示例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));
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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);
}