當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。