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


Java User类代码示例

本文整理汇总了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));
}
 
开发者ID:victorbuckservices,项目名称:workshop-spring-4.0-to-4.2,代码行数:18,代码来源:TransactionalTest.java

示例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());
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:11,代码来源:UserVehicleService.java

示例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);
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:10,代码来源:UserVehicleServiceTest.java

示例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());
}
 
开发者ID:victorbuckservices,项目名称:workshop-spring-4.0-to-4.2,代码行数:10,代码来源:TransactionalTest.java

示例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());
}
 
开发者ID:victorbuckservices,项目名称:workshop-spring-4.0-to-4.2,代码行数:10,代码来源:TransactionalTest.java

示例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();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:34,代码来源:ChannelController.java

示例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;
    }
 
开发者ID:nithril,项目名称:whisper,代码行数:14,代码来源:UsersManager.java

示例8: getUsers

import demo.domain.User; //导入依赖的package包/类
public List<User> getUsers() {
    return users;
}
 
开发者ID:nithril,项目名称:whisper,代码行数:4,代码来源:UsersManager.java

示例9: findUserByPrivateId

import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByPrivateId(String privateId){
    return users.stream().filter(u -> privateId.equals(u.getPrivateId())).findFirst();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:4,代码来源:UsersManager.java

示例10: findUserByPublicId

import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByPublicId(String publicId){
    return users.stream().filter(u -> publicId.equals(u.getPublicId())).findFirst();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:4,代码来源:UsersManager.java

示例11: findUserBySessionId

import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserBySessionId(String sessionId){
    return users.stream().filter(u -> sessionId.equals(u.getSessionId())).findFirst();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:4,代码来源:UsersManager.java

示例12: findUserByName

import demo.domain.User; //导入依赖的package包/类
public Optional<User> findUserByName(String name){
    return users.stream().filter(u -> name.equals(u.getName())).findFirst();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:4,代码来源:UsersManager.java


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