use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserDAO method findByUsername.
public MyUser findByUsername(final String username) {
final Query query = entityManager.createQuery("from MyUser where username=:username", MyUser.class);
query.setParameter("username", username);
final List<MyUser> result = query.getResultList();
if (result != null && result.size() > 0) {
return result.get(0);
} else
return null;
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserLiveTest method givenFirstName_whenGettingListOfUsers_thenCorrect.
@Test
public void givenFirstName_whenGettingListOfUsers_thenCorrect() {
final Response response = givenAuth().get(URL_PREFIX + "?firstName=john");
final MyUser[] result = response.as(MyUser[].class);
assertEquals(result.length, 1);
assertEquals(result[0].getEmail(), userJohn.getEmail());
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserLiveTest method givenEmail_whenGettingListOfUsers_thenIgnored.
@Test
public void givenEmail_whenGettingListOfUsers_thenIgnored() {
final Response response = givenAuth().get(URL_PREFIX + "?email=john");
final MyUser[] result = response.as(MyUser[].class);
assertEquals(result.length, 2);
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class MyUserLiveTest method whenGettingListOfUsers_thenCorrect.
@Test
public void whenGettingListOfUsers_thenCorrect() {
final Response response = givenAuth().get(URL_PREFIX);
final MyUser[] result = response.as(MyUser[].class);
assertEquals(result.length, 2);
}
use of org.baeldung.persistence.model.MyUser in project tutorials by eugenp.
the class JPAQuerydslIntegrationTest method givenWrongFirstAndLast_whenGettingListOfUsers_thenCorrect.
@Test
public void givenWrongFirstAndLast_whenGettingListOfUsers_thenCorrect() {
final MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder().with("firstName", ":", "adam").with("lastName", ":", "fox");
final Iterable<MyUser> results = repo.findAll(builder.build());
assertThat(results, emptyIterable());
}
Aggregations