Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d8c77d1af6
|
@ -1,18 +1,23 @@
|
||||||
package com.loafle.overflow.module.email.dao;
|
package com.loafle.overflow.module.email.dao;
|
||||||
|
|
||||||
import com.loafle.overflow.module.email.model.EmailAuth;
|
import com.loafle.overflow.module.email.model.EmailAuth;
|
||||||
|
import com.loafle.overflow.module.member.model.Member;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by geek@loafle.com on 17. 6. 6.
|
* Created by geek@loafle.com on 17. 6. 6.
|
||||||
*/
|
*/
|
||||||
@Repository
|
@Repository
|
||||||
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
|
public interface EmailAuthDAO extends JpaRepository<EmailAuth, Long> {
|
||||||
// public EmailAuth findByAuthToken(EmailAuth emailAuth);
|
@Query("select e from EmailAuth e where e.emailAuthKey = :authKey")
|
||||||
|
EmailAuth findByEmailAuthKey(@Param("authKey") String emailAuthKey);
|
||||||
|
|
||||||
// public List<EmailAuth> findByMemberId(EmailAuth emailAuth);
|
List<EmailAuth> findByMember(Member member);
|
||||||
|
|
||||||
// public EmailAuth updateEmailAuth(EmailAuth emailAuth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.loafle.overflow.module.email.dao;
|
||||||
|
|
||||||
|
import com.loafle.overflow.AppConfig;
|
||||||
|
import com.loafle.overflow.JdbcConfiguration;
|
||||||
|
import com.loafle.overflow.module.email.model.EmailAuth;
|
||||||
|
import com.loafle.overflow.module.member.model.Member;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by root on 17. 6. 23.
|
||||||
|
*/
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
|
||||||
|
public class EmailAuthDAOTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailAuthDAO dao;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestSaveEmailAuth() {
|
||||||
|
EmailAuth auth = new EmailAuth();
|
||||||
|
auth.setEmailAuthKey("dbseogns1234");
|
||||||
|
auth.setMember(new Member(1));
|
||||||
|
|
||||||
|
this.dao.save(auth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestFindByEmailAuthKey() {
|
||||||
|
EmailAuth auth = this.dao.findByEmailAuthKey("dbseogns1234");
|
||||||
|
assertEquals(1, auth.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void TestFindByMember() {
|
||||||
|
List<EmailAuth> auths = this.dao.findByMember(new Member((long)1));
|
||||||
|
|
||||||
|
assertEquals(1, auths.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user