本文整理汇总了Java中demo.domain.User类的典型用法代码示例。如果您正苦于以下问题:Java User类的具体用法?Java User怎么用?Java User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
User类属于demo.domain包,在下文中一共展示了User类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTransactional
import demo.domain.User; //导入依赖的package包/类
@Test
public void testTransactional() throws Exception {
User user = newUser().address("address").firstName("firstname").lastName("lastname").build();
user = userRepository.save(user);
TestTransaction.end();
Assert.assertEquals(0 , userRepository.findAll().size());
TestTransaction.start();
TestTransaction.flagForCommit();
user = newUser().address("address").firstName("firstname").lastName("lastname").build();
user = userRepository.save(user);
TestTransaction.end();
Assert.assertEquals(user, userRepository.findAll().get(0));
}
示例2: getVehicleDetails
import demo.domain.User; //导入依赖的package包/类
public VehicleDetails getVehicleDetails(String username)
throws UserNameNotFoundException,
VehicleIdentificationNumberNotFoundException {
Assert.notNull(username, "Username must not be null");
User user = this.userRepository.findByUsername(username);
if (user == null) {
throw new UserNameNotFoundException(username);
}
return this.vehicleDetailsService.getVehicleDetails(user.getVin());
}
示例3: getVehicleDetailsShouldReturnMakeAndModel
import demo.domain.User; //导入依赖的package包/类
@Test
public void getVehicleDetailsShouldReturnMakeAndModel() throws Exception {
given(this.userRepository.findByUsername("donald"))
.willReturn(new User("donald", VIN));
VehicleDetails details = new VehicleDetails("Honda", "Civic");
given(this.vehicleDetailsService.getVehicleDetails(VIN)).willReturn(details);
VehicleDetails actual = this.service.getVehicleDetails("donald");
assertThat(actual).isEqualTo(details);
}
示例4: testRollback
import demo.domain.User; //导入依赖的package包/类
@Test
@Rollback
public void testRollback() throws Exception {
User user = newUser().address("address").firstName("firstname").lastName("lastname").build();
user = userRepository.save(user);
TestTransaction.end();
Assert.assertEquals(0 , userRepository.findAll().size());
}
示例5: testCommit
import demo.domain.User; //导入依赖的package包/类
@Test
@Commit
public void testCommit() throws Exception {
User user = newUser().address("address").firstName("firstname").lastName("lastname").build();
user = userRepository.save(user);
TestTransaction.end();
Assert.assertEquals(1 , userRepository.findAll().size());
}
示例6: joinChannel
import demo.domain.User; //导入依赖的package包/类
@JsonView(Views.Public.class)
@RequestMapping(value = "/ui/channels", method = RequestMethod.POST, produces = "application/json")
public ResponseEntity joinChannel(@RequestBody Map body, HttpSession httpSession) {
String name = (String) body.get("name");
User user = usersManager.findUserBySessionId(httpSession.getId()).orElse(null);
if (user != null) {
Channel channel = channelsManager
.findByName(name)
.orElseGet(() -> channelsManager.addChannel(name));
channel.getUsers().add(user);
//Notify channel user
channel.getUsers().forEach(u -> {
try {
String json = objectMapper.writerWithView(Views.Public.class).writeValueAsString(channel);
this.messagingTemplate.convertAndSend("/queue/" + u.getPrivateId() + "/channel",
json);
} catch (JsonProcessingException e) {
LOG.error(e.getMessage() , e);
}
});
return ok(channel);
}
return ResponseEntity.notFound().build();
}
示例7: addUser
import demo.domain.User; //导入依赖的package包/类
public User addUser(String name, String publicKey, String sessionId) {
User user = new User();
user.setName(name);
user.setPublicKey(publicKey);
user.setPrivateId(UUID.randomUUID().toString());
user.setPublicId(UUID.randomUUID().toString());
user.setSessionId(sessionId);
users.add(user);
return user;
}
示例8: getUsers
import demo.domain.User; //导入依赖的package包/类
public List<User> getUsers() {
return users;
}
示例9: findUserByPrivateId
import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByPrivateId(String privateId){
return users.stream().filter(u -> privateId.equals(u.getPrivateId())).findFirst();
}
示例10: findUserByPublicId
import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByPublicId(String publicId){
return users.stream().filter(u -> publicId.equals(u.getPublicId())).findFirst();
}
示例11: findUserBySessionId
import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserBySessionId(String sessionId){
return users.stream().filter(u -> sessionId.equals(u.getSessionId())).findFirst();
}
示例12: findUserByName
import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByName(String name){
return users.stream().filter(u -> name.equals(u.getName())).findFirst();
}