spring-boot-realworld-examp.../src/test/java/io/spring/infrastructure/favorite/MyBatisArticleFavoriteRepos...

31 lines
1.1 KiB
Java
Raw Normal View History

2017-08-16 10:51:20 +07:00
package io.spring.infrastructure.favorite;
import io.spring.core.favorite.ArticleFavorite;
import io.spring.core.favorite.ArticleFavoriteRepository;
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 static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
@RunWith(SpringRunner.class)
@MybatisTest
@Import({MyBatisArticleFavoriteRepository.class})
public class MyBatisArticleFavoriteRepositoryTest {
@Autowired
private ArticleFavoriteRepository articleFavoriteRepository;
@Autowired
private ArticleFavoriteMapper articleFavoriteMapper;
@Test
public void should_save_and_fetch_articleFavorite_success() throws Exception {
ArticleFavorite articleFavorite = new ArticleFavorite("123", "456");
articleFavoriteRepository.save(articleFavorite);
assertThat(articleFavoriteMapper.find(articleFavorite), is(true));
}
}