use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserService method registerNewUserAccount.
public MyUser registerNewUserAccount(final MyUserDto accountDto) throws Exception {
if (usernameExists(accountDto.getUsername())) {
throw new Exception("There is an account with that username: " + accountDto.getUsername());
}
final MyUser user = new MyUser();
user.setUsername(accountDto.getUsername());
user.setPassword(passwordEncoder.encode(accountDto.getPassword()));
return myUserDAO.save(user);
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class JPAQuerydslIntegrationTest method init.
@Before
public void init() {
userJohn = new MyUser();
userJohn.setFirstName("john");
userJohn.setLastName("doe");
userJohn.setEmail("john@doe.com");
userJohn.setAge(22);
repo.save(userJohn);
userTom = new MyUser();
userTom.setFirstName("tom");
userTom.setLastName("doe");
userTom.setEmail("tom@doe.com");
userTom.setAge(26);
repo.save(userTom);
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class JPAQuerydslIntegrationTest method givenLastAndAge_whenGettingListOfUsers_thenCorrect.
@Test
public void givenLastAndAge_whenGettingListOfUsers_thenCorrect() {
final MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder().with("lastName", ":", "doe").with("age", ">", "25");
final Iterable<MyUser> results = repo.findAll(builder.build());
assertThat(results, contains(userTom));
assertThat(results, not(contains(userJohn)));
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class JPAQuerydslIntegrationTest method givenPartialFirst_whenGettingListOfUsers_thenCorrect.
@Test
public void givenPartialFirst_whenGettingListOfUsers_thenCorrect() {
final MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder().with("firstName", ":", "jo");
final Iterable<MyUser> results = repo.findAll(builder.build());
assertThat(results, contains(userJohn));
assertThat(results, not(contains(userTom)));
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserLiveTest method givenPartialLastName_whenGettingListOfUsers_thenCorrect.
@Test
public void givenPartialLastName_whenGettingListOfUsers_thenCorrect() {
final Response response = givenAuth().get(URL_PREFIX + "?lastName=do");
final MyUser[] result = response.as(MyUser[].class);
assertEquals(result.length, 2);
}
Aggregations