From 7282b0493bba85309953e880e01bb41567737872 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 23 Jun 2017 16:36:50 +0900 Subject: [PATCH] added test --- .../module/apikey/dao/ApiKeyDAOTest.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/test/java/com/loafle/overflow/module/apikey/dao/ApiKeyDAOTest.java diff --git a/src/test/java/com/loafle/overflow/module/apikey/dao/ApiKeyDAOTest.java b/src/test/java/com/loafle/overflow/module/apikey/dao/ApiKeyDAOTest.java new file mode 100644 index 0000000..e7dca0c --- /dev/null +++ b/src/test/java/com/loafle/overflow/module/apikey/dao/ApiKeyDAOTest.java @@ -0,0 +1,54 @@ +package com.loafle.overflow.module.apikey.dao; + +import com.loafle.overflow.AppConfig; +import com.loafle.overflow.JdbcConfiguration; +import com.loafle.overflow.module.apikey.model.ApiKey; +import com.loafle.overflow.module.domain.Domain; +import org.junit.Assert; +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 static org.junit.Assert.*; + +/** + * Created by root on 17. 6. 23. + */ +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class}) +public class ApiKeyDAOTest { + + @Autowired + private ApiKeyDAO apiKeyDAO; + + @Test + public void create() { + + ApiKey apiKey = new ApiKey(); + + apiKey.setApiKey("52abd6fd57e511e7ac52080027658d13"); + + Domain domain = new Domain(); + domain.setId(1); + + apiKey.setDomain(domain); + + this.apiKeyDAO.save(apiKey); + + + Assert.assertNotEquals(apiKey.getId(), 0); + } + + @Test + public void findByApiKey() throws Exception { + + ApiKey apiKey = this.apiKeyDAO.findByApiKey("52abd6fd57e511e7ac52080027658d13"); + + + Assert.assertNotEquals(apiKey, null); + + } + +} \ No newline at end of file