36 lines
1.3 KiB
Java
36 lines
1.3 KiB
Java
|
package io.spring.application.profile;
|
||
|
|
||
|
import io.spring.core.user.User;
|
||
|
import io.spring.core.user.UserRepository;
|
||
|
import io.spring.infrastructure.user.MyBatisUserRepository;
|
||
|
import org.junit.Test;
|
||
|
import org.junit.runner.RunWith;
|
||
|
import org.mybatis.spring.boot.test.autoconfigure.MybatisTest;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.context.annotation.Import;
|
||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||
|
|
||
|
import java.util.Optional;
|
||
|
|
||
|
import static org.hamcrest.CoreMatchers.is;
|
||
|
import static org.junit.Assert.*;
|
||
|
|
||
|
@RunWith(SpringRunner.class)
|
||
|
@MybatisTest
|
||
|
@Import({ProfileQueryService.class, MyBatisUserRepository.class})
|
||
|
public class ProfileQueryServiceTest {
|
||
|
@Autowired
|
||
|
private ProfileQueryService profileQueryService;
|
||
|
@Autowired
|
||
|
private UserRepository userRepository;
|
||
|
|
||
|
@Test
|
||
|
public void should_fetch_profile_success() throws Exception {
|
||
|
User currentUser = new User("a@test.com", "a", "123", "", "");
|
||
|
User profileUser = new User("p@test.com", "p", "123", "", "");
|
||
|
userRepository.save(profileUser);
|
||
|
|
||
|
Optional<ProfileData> optional = profileQueryService.findByUsername(profileUser.getUsername(), currentUser);
|
||
|
assertThat(optional.isPresent(), is(true));
|
||
|
}
|
||
|
}
|