Package by.fly.repository

Source Code of by.fly.repository.UserRepositoryTest

package by.fly.repository;

import by.fly.model.QUser;
import by.fly.model.User;
import by.fly.service.OrganizationService;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.junit.Assert.assertThat;

public class UserRepositoryTest extends AbstractBaseTest {

    @Autowired
    UserRepository userRepository;

    @Autowired
    JpaRepository<User, Long> userJpaRepository;

    @Autowired
    OrganizationService organizationService;

    @Test
    public void testRepo() {
        String login = String.valueOf(System.currentTimeMillis());
        String name = "Валера";

        User user = new User(login, null, login, organizationService.getRootOrganization());
        user.setName(name);
        userJpaRepository.save(user);

        Iterable<User> users = userRepository.findAll(QUser.user.name.eq(name).and(QUser.user.login.eq(login)));
        assertThat(users, hasItem(user));
    }

}
TOP

Related Classes of by.fly.repository.UserRepositoryTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.