init
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.eactive.eai.authserver.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.authserver" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = { "com.eactive.eai.authserver" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.authserver" })
|
||||
@Sql({ "/com/eactive/eai/authserver/init_tseaiau01.sql" })
|
||||
class ClientDAOTest {
|
||||
|
||||
@Autowired
|
||||
ClientDAO clientDAO;
|
||||
|
||||
@Test
|
||||
void testLoadClientDetails() throws DAOException {
|
||||
// given
|
||||
|
||||
// when
|
||||
clientDAO.loadClientDetails();
|
||||
|
||||
// then
|
||||
assertNotNull(clientDAO.loadClientDetails());
|
||||
assertTrue(clientDAO.loadClientDetails().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetClientByI() throws DAOException {
|
||||
// given
|
||||
String clientId = "R4v8qDMVOmLJ1X4yKQslrKmhVOu2TNb2";
|
||||
// when
|
||||
clientDAO.getClientById(clientId);
|
||||
|
||||
// then
|
||||
assertNotNull(clientDAO.getClientById(clientId));
|
||||
assertTrue(clientDAO.getClientById(clientId).getClientId().length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.eactive.eai.authserver.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.authserver" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.authserver" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.authserver" })
|
||||
@Sql({ "/com/eactive/eai/authserver/init_tseaiau04.sql" })
|
||||
class ScopeDAOTest {
|
||||
|
||||
@Autowired
|
||||
ScopeDAO scopeDAO;
|
||||
|
||||
@Test
|
||||
void testLoadApiScopeRelations() throws DAOException {
|
||||
// given
|
||||
|
||||
// when
|
||||
scopeDAO.loadApiScopeRelations();
|
||||
|
||||
// then
|
||||
assertNotNull(scopeDAO.loadApiScopeRelations());
|
||||
assertTrue(scopeDAO.loadApiScopeRelations().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetApiScopeRelationsByApiId() throws DAOException {
|
||||
// given
|
||||
String apiId = "test.Bzwksvckeyname";
|
||||
// when
|
||||
scopeDAO.getApiScopeRelationsByApiId(apiId);
|
||||
|
||||
// then
|
||||
assertNotNull(scopeDAO.getApiScopeRelationsByApiId(apiId));
|
||||
assertTrue(scopeDAO.getApiScopeRelationsByApiId(apiId).size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetApiScopeRelationsByScopeId() throws DAOException {
|
||||
// given
|
||||
String scopeId = "invest.account";
|
||||
// when
|
||||
scopeDAO.getApiScopeRelationsByScopeId(scopeId);
|
||||
|
||||
// then
|
||||
assertNotNull(scopeDAO.getApiScopeRelationsByScopeId(scopeId));
|
||||
assertTrue(scopeDAO.getApiScopeRelationsByScopeId(scopeId).size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHasApiScopeRelation() throws DAOException {
|
||||
// given
|
||||
String apiId = "test.Bzwksvckeyname";
|
||||
String scopeId = "test.Scopeid";
|
||||
// when
|
||||
scopeDAO.hasApiScopeRelation(apiId, scopeId);
|
||||
|
||||
// then
|
||||
assertTrue(scopeDAO.hasApiScopeRelation(apiId, scopeId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
package com.eactive.eai.authserver.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.authserver" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = { "com.eactive.eai.authserver" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.authserver" })
|
||||
@Sql({ "/com/eactive/eai/authserver/init_tseaiau02.sql" })
|
||||
class UserDAOTest {
|
||||
|
||||
@Autowired
|
||||
UserDAO userDAO;
|
||||
|
||||
@Test
|
||||
void testStart() throws DAOException {
|
||||
// given
|
||||
String userId = "testId";
|
||||
|
||||
// when
|
||||
userDAO.getUserByUserId(userId);
|
||||
|
||||
// then
|
||||
assertNotNull(userDAO.getUserByUserId(userId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.authserver.service;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.authserver" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = { "com.eactive.eai.authserver" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.authserver" })
|
||||
@Sql({ "/com/eactive/eai/authserver/init_tseaiau01.sql", "/com/eactive/eai/authserver/init_tseaiau04.sql" })
|
||||
class OAuth2ManagerTest {
|
||||
|
||||
@Autowired
|
||||
OAuth2Manager oAuth2Manager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
oAuth2Manager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(oAuth2Manager.getApiScopeMap());
|
||||
assertTrue(oAuth2Manager.getApiScopeMap().size() > 0);
|
||||
assertNotNull(oAuth2Manager.getClientDeatilsStore());
|
||||
assertTrue(oAuth2Manager.getClientDeatilsStore().size() > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.eactive.eai.authserver.service;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.authserver" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = { "com.eactive.eai.authserver" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.authserver" })
|
||||
@Sql({ "/com/eactive/eai/authserver/init_tseaiau02.sql" })
|
||||
class UserDetailsServiceImplTest {
|
||||
|
||||
@Autowired
|
||||
UserDetailsServiceImpl userDetailsServiceImpl;
|
||||
|
||||
@Test
|
||||
void testStart() throws DAOException {
|
||||
// given
|
||||
String userId = "testId";
|
||||
// when
|
||||
userDetailsServiceImpl.loadUserByUsername(userId);
|
||||
|
||||
// then
|
||||
assertNotNull(userDetailsServiceImpl.loadUserByUsername(userId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class, EAIServerManager.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.b2badaptermapping" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.b2badaptermapping" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.b2badaptermapping" })
|
||||
@Sql({ "/com/eactive/eai/common/b2badaptermapping/init_tseaifr07.sql" })
|
||||
class B2BAdapterMapDAOTest {
|
||||
|
||||
@SpyBean
|
||||
B2BAdapterMapDAO b2bAdapterMapDAO;
|
||||
|
||||
@MockBean
|
||||
private EAIServerManager eaiServerManager;
|
||||
|
||||
@Test
|
||||
void getAllB2BAdapterMapsTest() throws Exception {
|
||||
// given
|
||||
String eaiInstCd = "fepOnlSvr12";
|
||||
|
||||
// when
|
||||
b2bAdapterMapDAO.getAllB2BAdapterMaps(eaiInstCd);
|
||||
|
||||
// then
|
||||
assertNotNull(b2bAdapterMapDAO.getAllB2BAdapterMaps(eaiInstCd));
|
||||
assertTrue(b2bAdapterMapDAO.getAllB2BAdapterMaps(eaiInstCd).size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getB2BAdapterMapTest() throws Exception {
|
||||
// given
|
||||
String eaiInstCd = "fepOnlSvr22";
|
||||
String eaiSvcCd = "ATS0210012270R2";
|
||||
|
||||
// when
|
||||
b2bAdapterMapDAO.getB2BAdapterMap(eaiInstCd, eaiSvcCd);
|
||||
|
||||
// then
|
||||
assertNotNull(b2bAdapterMapDAO.getB2BAdapterMap(eaiInstCd, eaiSvcCd));
|
||||
assertTrue(b2bAdapterMapDAO.getB2BAdapterMap(eaiInstCd, eaiSvcCd).size() > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.eactive.eai.common.b2badaptermapping;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class, EAIServerManager.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.b2badaptermapping" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.b2badaptermapping" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.b2badaptermapping" })
|
||||
@Sql({ "/com/eactive/eai/common/b2badaptermapping/init_tseaifr07.sql" })
|
||||
class B2BAdapterMapManagerTest {
|
||||
|
||||
@SpyBean
|
||||
B2BAdapterMapManager b2bAdapterMapManager;
|
||||
|
||||
@MockBean
|
||||
private EAIServerManager eaiServerManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws Exception {
|
||||
// given
|
||||
given(eaiServerManager.getLocalServerName()).willReturn("fepOnlSvr12");
|
||||
|
||||
// when
|
||||
b2bAdapterMapManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(b2bAdapterMapManager.getAllKeyNames());
|
||||
assertTrue(b2bAdapterMapManager.getAllKeyNames().length > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.common.b2bextractor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.SpyBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.b2bextractor" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.b2bextractor" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.b2bextractor" })
|
||||
@Sql({ "/com/eactive/eai/common/b2bextractor/init_tseaifr06.sql" })
|
||||
class B2BExtractManagerTest {
|
||||
|
||||
@SpyBean
|
||||
B2BExtractManager b2bExtractManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
b2bExtractManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(b2bExtractManager.getAllKeyNames());
|
||||
assertTrue(b2bExtractManager.getAllKeyNames().length > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.eactive.eai.common.b2bservice;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.b2bservice" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.b2bservice" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.b2bservice" })
|
||||
@Sql({ "/com/eactive/eai/common/b2bservice/init_tseaihe03.sql" })
|
||||
class B2BServiceManagerTest {
|
||||
|
||||
@Autowired
|
||||
B2BServiceManager b2bServiceManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
b2bServiceManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(b2bServiceManager.getAllKeys());
|
||||
assertTrue(b2bServiceManager.getAllKeys().length > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.bizkey" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.bizkey" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.bizkey" })
|
||||
@Sql({ "/com/eactive/eai/common/bizkey/init_tseaifr03.sql" })
|
||||
class BizKeyDAOTest {
|
||||
@Autowired
|
||||
BizKeyDAO bizKeyDAO;
|
||||
|
||||
@Test
|
||||
void getAllBizKeysTest() throws Exception {
|
||||
// given
|
||||
|
||||
// when
|
||||
bizKeyDAO.getAllBizKeys();
|
||||
|
||||
// then
|
||||
assertNotNull(bizKeyDAO.getAllBizKeys());
|
||||
assertTrue(bizKeyDAO.getAllBizKeys().size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getBizKeyTest() throws Exception {
|
||||
// given
|
||||
String eaiSvcCd = "AC1B805Q01S2";
|
||||
String exrClsNm = "TR";
|
||||
|
||||
// when
|
||||
bizKeyDAO.getBizKey(eaiSvcCd, exrClsNm);
|
||||
|
||||
// then
|
||||
assertNotNull(bizKeyDAO.getBizKey(eaiSvcCd, exrClsNm));
|
||||
assertTrue(bizKeyDAO.getBizKey(eaiSvcCd, exrClsNm).size() > 0);
|
||||
assertTrue(bizKeyDAO.getBizKey(eaiSvcCd, exrClsNm).toString().length() > 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.common.bizkey;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.bizkey" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.bizkey" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.bizkey" })
|
||||
@Sql({ "/com/eactive/eai/common/bizkey/init_tseaifr03.sql" })
|
||||
class BizKeyManagerTest {
|
||||
@Autowired
|
||||
BizKeyManager bizKeyManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
bizKeyManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(bizKeyManager.getAllKeyNames());
|
||||
assertTrue(bizKeyManager.getAllKeyNames().length > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.eactive.eai.common.c2rservice;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.c2rservice" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.c2rservice" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.c2rservice" })
|
||||
@Sql({ "/com/eactive/eai/common/c2rservice/init_tseaihe04.sql" })
|
||||
class C2RServiceDAOTest {
|
||||
|
||||
@Autowired
|
||||
C2RServiceDAO c2rServiceDAO;
|
||||
|
||||
@Test
|
||||
void getAllC2RServices() throws DAOException {
|
||||
// given
|
||||
|
||||
// when
|
||||
c2rServiceDAO.getAllC2RServices();
|
||||
|
||||
// then
|
||||
assertNotNull(c2rServiceDAO.getAllC2RServices());
|
||||
assertTrue(c2rServiceDAO.getAllC2RServices().size() > 0);
|
||||
}
|
||||
|
||||
// @Test
|
||||
// void testStart() throws DAOException {
|
||||
// // given
|
||||
// String c2rExtnlInstiCd = "50500226";
|
||||
//
|
||||
// // when
|
||||
// c2rServiceDAO.getC2RService(c2rExtnlInstiCd);
|
||||
//
|
||||
// // then
|
||||
//// assertNotNull(c2rServiceDAO.getC2RService(c2rExtnlInstiCd));
|
||||
// assertTrue(c2rServiceDAO.getC2RService(c2rExtnlInstiCd).size() > 0);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.eactive.eai.common.c2rservice;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.c2rservice" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.c2rservice" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.c2rservice" })
|
||||
@Sql({ "/com/eactive/eai/common/c2rservice/init_tseaihe04.sql" })
|
||||
class C2RServiceManagerTest {
|
||||
|
||||
@Autowired
|
||||
C2RServiceManager c2rServiceManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
c2rServiceManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(c2rServiceManager.getAllKeys());
|
||||
assertTrue(c2rServiceManager.getAllKeys().length > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.inflow;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.inflow" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.inflow" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.inflow" })
|
||||
@Sql({ "/com/eactive/eai/common/inflow/init_tseaifr09.sql", "/com/eactive/eai/common/inflow/init_tseaifr11.sql" })
|
||||
class InflowControlManagerTest {
|
||||
|
||||
@Autowired
|
||||
InflowControlManager inflowControlManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
inflowControlManager.start();
|
||||
|
||||
// then
|
||||
assertTrue(inflowControlManager.isStarted());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.message" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.message" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.message" })
|
||||
@Sql({ "/com/eactive/eai/common/message/init_tseaihe01.sql", "/com/eactive/eai/common/message/init_tseaihe02.sql",
|
||||
"/com/eactive/eai/common/message/init_tseaifr01.sql", "/com/eactive/eai/common/message/init_tseaims02.sql" })
|
||||
class EAIMessageDAOTest {
|
||||
@Autowired
|
||||
EAIMessageDAO eaiMessageDAO;
|
||||
|
||||
@Test
|
||||
void getAllEAIMessages() throws DAOException {
|
||||
// given
|
||||
|
||||
// when
|
||||
eaiMessageDAO.getAllEAIMessages();
|
||||
|
||||
// then
|
||||
assertNotNull(eaiMessageDAO.getAllEAIMessages());
|
||||
assertTrue(eaiMessageDAO.getAllEAIMessages().size() > 0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void getEAIMessagesByCode() throws DAOException {
|
||||
// given
|
||||
String code = "EDDMIAS00000028S1";
|
||||
// when
|
||||
eaiMessageDAO.getEAIMessagesByCode(code);
|
||||
|
||||
// then
|
||||
assertNotNull(eaiMessageDAO.getEAIMessagesByCode(code));
|
||||
assertTrue(eaiMessageDAO.getEAIMessagesByCode(code).getEAISvcCd().length() > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.eactive.eai.common.message;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.message" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.message" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.message" })
|
||||
@Sql({ "/com/eactive/eai/common/message/init_tseaihe01.sql", "/com/eactive/eai/common/message/init_tseaihe02.sql",
|
||||
"/com/eactive/eai/common/message/init_tseaims02.sql", "/com/eactive/eai/common/message/init_tseaifr01.sql" })
|
||||
class EAIMessageManagerTest {
|
||||
@Autowired
|
||||
EAIMessageManager eaiMessageManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
eaiMessageManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(eaiMessageManager.getAllEAISvcCd());
|
||||
assertTrue(eaiMessageManager.getAllEAISvcCd().length > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.eactive.eai.common.messagekey;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.messagekey" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.messagekey" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.messagekey" })
|
||||
@Sql({ "/com/eactive/eai/common/messagekey/init_tseaifr04.sql" })
|
||||
class MessageKeyManagerTest {
|
||||
|
||||
@Autowired
|
||||
MessageKeyManager messageKeyManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
messageKeyManager.start();
|
||||
|
||||
// then
|
||||
assertTrue(messageKeyManager.getAllKeyNames().length > 0);
|
||||
|
||||
MessageKeyVO vo = messageKeyManager.getMessageKey("_EAI_IN_NET_SyS" + "I");
|
||||
System.out.println(vo);
|
||||
assertTrue(vo.getMessageKeyGroup(0).getMessageKeyFldLength() == 2);
|
||||
|
||||
try {
|
||||
vo = messageKeyManager.getMessageKey("_EAI_IN_NET_SyS", "I");
|
||||
} catch (DAOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println(vo);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.eactive.eai.common.pushinfo;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.pushinfo.PushInfoDetailVO.Result;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.pushinfo" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.pushinfo" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.pushinfo" })
|
||||
class PushInfoDAOTest {
|
||||
@Autowired
|
||||
PushInfoDAO pushInfoDAO;
|
||||
|
||||
@Test
|
||||
void test() throws DAOException {
|
||||
// given
|
||||
String guid = "guid001";
|
||||
int count = 2;
|
||||
PushInfoVO vo = new PushInfoVO();
|
||||
vo.setGuid(guid);
|
||||
vo.setPushTargetCount(count);
|
||||
vo.setPushTarget("0001,0002");
|
||||
// when
|
||||
pushInfoDAO.insertPushInfo(vo);
|
||||
|
||||
List<PushInfoDetailVO> list = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
PushInfoDetailVO detail = new PushInfoDetailVO();
|
||||
detail.setGuid("GUID" + i);
|
||||
detail.setPushResult(Result.success);
|
||||
list.add(detail);
|
||||
}
|
||||
pushInfoDAO.batchInsertPushInfoDetail(list);
|
||||
// then
|
||||
assertTrue(pushInfoDAO.getPushInfoDetailCount() == 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.routing;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.routing" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.routing" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.routing" })
|
||||
@Sql({ "/com/eactive/eai/common/routing/init_tseaifr02.sql" })
|
||||
class RoutingManagerTest {
|
||||
|
||||
@Autowired
|
||||
RoutingManager routingManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
routingManager.start();
|
||||
|
||||
// then
|
||||
assertTrue(routingManager.getAllRoutingNames().length > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.common.sessioninfo" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.common.sessioninfo" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.sessioninfo" })
|
||||
public class SessionInfoDAOTest {
|
||||
@Autowired
|
||||
SessionInfoDAO sessioninfoDAO;
|
||||
|
||||
// @Test
|
||||
// @Transactional(propagation = Propagation.NOT_SUPPORTED)
|
||||
// void testStart() throws DAOException {
|
||||
// // given
|
||||
// String userId = "test001";
|
||||
// String sessionId = "session-001";
|
||||
// SessionInfoVO vo = new SessionInfoVO(userId);
|
||||
// vo.setSessionId(sessionId);
|
||||
// // when
|
||||
// sessioninfoDAO.upsertSessionInfo(vo);
|
||||
//
|
||||
// vo.setSessionId("session-002");
|
||||
// sessioninfoDAO.upsertSessionInfo(vo);
|
||||
// // then
|
||||
// SessionInfoVO readVo = sessioninfoDAO.getSessionInfo(userId);
|
||||
// System.out.println("readVo ===>" + readVo.toString());
|
||||
// assertFalse(sessionId.equals(readVo.getSessionId()));
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.eactive.eai.data;
|
||||
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
import com.eactive.eai.common.util.ApplicationContextProvider;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@Configuration
|
||||
@ComponentScan({ "com.eactive.eai.property" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = { "com.eactive.eai.property" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.property" })
|
||||
public class CommonJPATestConfiguration {
|
||||
|
||||
@Bean
|
||||
ApplicationContextProvider applicationContextProvider() {
|
||||
return new ApplicationContextProvider();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.eactive.eai.flowcontrol.jms;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.flowcontrol.jms" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.flowcontrol.jms" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.flowcontrol.jms" })
|
||||
@Sql({ "/com/eactive/eai/flowcontrol/jms/init_tseaiqm02.sql" })
|
||||
class FCQueueReceiverDAOTest {
|
||||
|
||||
@Autowired
|
||||
FCQueueReceiverDAO fcQueueReceiverDAO;
|
||||
|
||||
// @Test
|
||||
// void getAllReceivers() throws DAOException {
|
||||
// // given
|
||||
//
|
||||
// // when
|
||||
// fcQueueReceiverDAO.getAllReceivers();
|
||||
//
|
||||
// // then
|
||||
// assertNotNull(fcQueueReceiverDAO.getAllReceivers());
|
||||
// assertTrue(fcQueueReceiverDAO.getAllReceivers().size() > 0);
|
||||
// }
|
||||
|
||||
@Test
|
||||
void getReceiver() throws DAOException {
|
||||
// given
|
||||
String queRcverName = "FlowRouterQueue_0101";
|
||||
|
||||
// when
|
||||
fcQueueReceiverDAO.getReceiver(queRcverName);
|
||||
|
||||
// then
|
||||
assertNotNull(fcQueueReceiverDAO.getReceiver(queRcverName));
|
||||
assertTrue(fcQueueReceiverDAO.getReceiver(queRcverName).getQueueName().length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.eactive.eai.flowcontrol.jms;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.flowcontrol.jms" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.flowcontrol.jms" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.flowcontrol.jms" })
|
||||
@Sql({ "/com/eactive/eai/flowcontrol/jms/init_tseaiqm02.sql" })
|
||||
class FCQueueReceiverManagerTest {
|
||||
@Autowired
|
||||
FCQueueReceiverManager fcQueueReceiverManager;
|
||||
|
||||
@MockBean
|
||||
EAIServerManager eaiServerManager;
|
||||
|
||||
@Test
|
||||
void getAllReceivers() throws LifecycleException {
|
||||
// given
|
||||
given(eaiServerManager.getLocalServerName()).willReturn("fepSvr11");
|
||||
// when
|
||||
fcQueueReceiverManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(fcQueueReceiverManager.getAllFCQueueReceiverVos());
|
||||
assertTrue(fcQueueReceiverManager.getAllFCQueueReceiverVos().size() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.eactive.eai.flowcontrol.jms;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.dao.DAOException;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class, EAIServerManager.class })
|
||||
@ComponentScan({ "com.eactive.eai.flowcontrol.jms" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.flowcontrol.jms" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.flowcontrol.jms" })
|
||||
@Sql({ "/com/eactive/eai/flowcontrol/jms/init_tseaiqm01.sql" })
|
||||
class QueueMonitorDAOTest {
|
||||
|
||||
@Autowired
|
||||
QueueMonitorDAO queueMonitorDAO;
|
||||
|
||||
@MockBean
|
||||
EAIServerManager eaiServerManager;
|
||||
|
||||
@Test
|
||||
void getAllC2RServices() throws DAOException {
|
||||
// given
|
||||
given(eaiServerManager.getLocalServerName()).willReturn("fepSvr11");
|
||||
|
||||
// when
|
||||
queueMonitorDAO.getAllQueue();
|
||||
|
||||
// then
|
||||
assertNotNull(queueMonitorDAO.getAllQueue());
|
||||
assertTrue(queueMonitorDAO.getAllQueue().size() > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.eactive.eai.flowcontrol.jms;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.common.server.EAIServerManager;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class, EAIServerManager.class })
|
||||
@ComponentScan({ "com.eactive.eai.flowcontrol.jms" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.flowcontrol.jms" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.flowcontrol.jms" })
|
||||
@Sql({ "/com/eactive/eai/flowcontrol/jms/init_tseaiqm01.sql" })
|
||||
class QueueMonitorManagerTest {
|
||||
|
||||
@Autowired
|
||||
QueueMonitorManager queueMonitorManager;
|
||||
|
||||
@MockBean
|
||||
EAIServerManager eaiServerManager;
|
||||
|
||||
@Test
|
||||
void getAllC2RServices() throws LifecycleException {
|
||||
// given
|
||||
given(eaiServerManager.getLocalServerName()).willReturn("fepSvr11");
|
||||
|
||||
// when
|
||||
queueMonitorManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(queueMonitorManager.getAllQueueMonitorVos());
|
||||
assertTrue(queueMonitorManager.getAllQueueMonitorVos().size() > 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.httpouttlsinfo;
|
||||
|
||||
import com.eactive.eai.common.lifecycle.LifecycleException;
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.httpouttlsinfo" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.httpouttlsinfo" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.httpouttlsinfo" })
|
||||
@Sql({ "/com/eactive/eai/httpouttlsinfo/init_http_tls_client_info.sql" })
|
||||
class HttpOutTlsInfoManagerTest {
|
||||
|
||||
@Autowired
|
||||
HttpOutTlsInfoManager httpOutTlsInfoManager;
|
||||
|
||||
@Test
|
||||
void testStart() throws LifecycleException {
|
||||
// given
|
||||
|
||||
// when
|
||||
httpOutTlsInfoManager.start();
|
||||
|
||||
// then
|
||||
assertNotNull(httpOutTlsInfoManager.getAllClientIds());
|
||||
assertTrue(httpOutTlsInfoManager.getAllClientIds().length > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.eactive.eai.message.layout;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
|
||||
import com.eactive.eai.data.CommonJPATestConfiguration;
|
||||
import com.eactive.eai.data.jpa.BaseRepositoryImpl;
|
||||
import com.eactive.eai.message.StandardItem;
|
||||
|
||||
@DataJpaTest
|
||||
@ContextConfiguration(classes = { CommonJPATestConfiguration.class })
|
||||
@ComponentScan({ "com.eactive.eai.message.layout", "com.eactive.eai.common.stdmessage" })
|
||||
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class, basePackages = {
|
||||
"com.eactive.eai.message.layout", "com.eactive.eai.common.stdmessage" })
|
||||
@EntityScan({ "com.eactive.eai.data.entity.onl.stdmessage" })
|
||||
@Sql({ "/com/eactive/eai/message/layout/DatabaseReaderTest.sql" })
|
||||
class DatabaseReaderTest {
|
||||
|
||||
@Autowired
|
||||
DatabaseReader databaseReader;
|
||||
|
||||
String layoutName = "HANA_POC_SAMPLE";
|
||||
|
||||
@Test
|
||||
void testParse() throws Exception {
|
||||
|
||||
List<StandardItem> list = databaseReader.parse(layoutName);
|
||||
|
||||
assertThat(list).isNotEmpty();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.eactive.eai.message.test;
|
||||
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.message.service.InterfaceMapper;
|
||||
import com.eactive.eai.message.service.InterfaceMessage;
|
||||
|
||||
public class InterfaceTest {
|
||||
static Logger logger = LoggerFactory.getLogger(InterfaceTest.class);
|
||||
|
||||
public InterfaceTest() {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// System.setProperty(StandardMessageManager.STANDARD_MESSAGE_CONFIG, "./resources/standard-message-config-test.properties");
|
||||
System.setProperty(StandardMessageManager.STANDARD_MESSAGE_CONFIG, "./resources/standard-message-config.properties");
|
||||
testInterfaceWithManager();
|
||||
}
|
||||
|
||||
public static void testInterfaceWithManager() {
|
||||
StandardMessageManager manager = StandardMessageManager.getInstance();
|
||||
try {
|
||||
manager.init();
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
StandardMessage standardMessage = manager.getStandardMessage();
|
||||
InterfaceMapper mapper = manager.getMapper();
|
||||
|
||||
String serviceCode = mapper.getEaiSvcCode(standardMessage);
|
||||
|
||||
// get Interface message with serviceCode
|
||||
InterfaceMessage interfaceMessage = new InterfaceMessage();
|
||||
|
||||
interfaceMessage.setStandardMessage(standardMessage);
|
||||
interfaceMessage.setMapper(mapper);
|
||||
|
||||
logger.debug(">> Init.");
|
||||
logger.debug("getServiceId = {}",interfaceMessage.getMapper().getServiceId(interfaceMessage.getStandardMessage()));
|
||||
logger.debug("getGuid = {}",interfaceMessage.getMapper().getGuid(interfaceMessage.getStandardMessage()));
|
||||
logger.debug("getReturnType = {}",interfaceMessage.getMapper().getSendRecvDivision(interfaceMessage.getStandardMessage()));
|
||||
logger.debug("getReturnType = {}",interfaceMessage.getMapper().getSendRecvDivision(interfaceMessage.getStandardMessage()));
|
||||
|
||||
logger.debug("getEaiSvcCode = {}", interfaceMessage.getMapper().getEaiSvcCode(standardMessage));
|
||||
logger.debug("standardMessage = {}",interfaceMessage.getStandardMessage().toPrettyJson());
|
||||
|
||||
String changed = "ELKCHANGED";
|
||||
logger.debug("\n>> Change : setServiceId = {}", changed);
|
||||
interfaceMessage.getMapper().setServiceId(interfaceMessage.getStandardMessage(), changed);
|
||||
interfaceMessage.getMapper().setErrorCode(interfaceMessage.getStandardMessage(), "ERR01");
|
||||
interfaceMessage.getMapper().setErrorMsg(interfaceMessage.getStandardMessage(), "내부처리 중 에러");
|
||||
interfaceMessage.getMapper().setResponseType(interfaceMessage.getStandardMessage(), "E");
|
||||
|
||||
logger.debug("getServiceId = {}",mapper.getServiceId(interfaceMessage.getStandardMessage()));
|
||||
logger.debug("getEaiSvcCode = {}", interfaceMessage.getMapper().getEaiSvcCode(standardMessage));
|
||||
|
||||
try {
|
||||
interfaceMessage.getStandardMessage().setBizData("{\"response\":\"response message is here!\"}", "utf-8");
|
||||
} catch (Exception e) {
|
||||
logger.error("bizdata set error", e);
|
||||
}
|
||||
logger.debug("toPrettyJson = {}",interfaceMessage.getStandardMessage().toPrettyJson());
|
||||
|
||||
try {
|
||||
interfaceMessage.getStandardMessage().setBizData("<response>response message is here!</response>", "utf-8");
|
||||
} catch (Exception e) {
|
||||
logger.error("bizdata set error", e);
|
||||
}
|
||||
logger.debug("toXML = {}",interfaceMessage.getStandardMessage().toPrettyXML());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
package com.eactive.eai.message.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.eactive.eai.message.StandardItem;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.StandardMessageUtil;
|
||||
import com.eactive.eai.message.StandardType;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.message.parser.StandardReader;
|
||||
import com.eactive.eai.message.parser.XmlReader;
|
||||
|
||||
public class SrandardMessageTest {
|
||||
static Logger logger = LoggerFactory.getLogger(SrandardMessageTest.class);
|
||||
static String strString =
|
||||
"000199GIDNO00000000004444 ELINKSVC01ELINK TEST Service SSESSIONID001 NO SCREEN0000001000000000100000000020000000003 USER000001 EACTEACT001ELINK01CHEA20220928000000000 S TESTSET-BIZDATA";
|
||||
|
||||
static String jsonString =
|
||||
"{"
|
||||
+ " \"msg_len\":199,"
|
||||
+ " \"global_id\":\"GIDNO00000000002222\","
|
||||
+ " \"service_id\":\"ELINKSVC01\","
|
||||
+ " \"service_cmt\":\"ELINK TEST Service\","
|
||||
+ " \"service_tn\":\"S\","
|
||||
+ " \"Session_id\":\"SESSIONID001\","
|
||||
+ " \"encrypt_yn\":\"NO\","
|
||||
+ " \"http_url\":\"\","
|
||||
+ " \"screen_id\":\"SCREEN0000001\","
|
||||
+ " \"scr_no\":\"000000000100000000020000000003\","
|
||||
+ " \"scr_dsc\":\"\","
|
||||
+ " \"usr_id\":\"USER000001\","
|
||||
+ " \"ip_addr\":\"\","
|
||||
+ " \"ip_mac\":\"\","
|
||||
+ " \"com_code\":\"EACT\","
|
||||
+ " \"head_code\":\"EACT001\","
|
||||
+ " \"dept_cd\":\"ELINK01\","
|
||||
+ " \"conn_tp\":\"CH\","
|
||||
+ " \"Inter_chn\":\"EA\","
|
||||
+ " \"recv_tm\":\"20220928000000000\","
|
||||
+ " \"send_tm\":\"\","
|
||||
+ " \"return_gubun\":\"S\","
|
||||
+ " \"return_value\":\"\","
|
||||
+ " \"msg_id\":\"\","
|
||||
+ " \"msg_nm\":\"\","
|
||||
+ " \"filler\":\"\","
|
||||
+ " \"bizData\":{"
|
||||
+ " \"bizfield1\":\"BIZ1\","
|
||||
+ " \"bizfield2\":\"BIZ2\","
|
||||
+ " \"bizfield3\":\"BIZ3\""
|
||||
+ " }"
|
||||
+ "}";
|
||||
|
||||
static String xmlString =
|
||||
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
||||
+ "<Root>"
|
||||
+ " <msg_len>199</msg_len>"
|
||||
+ " <global_id>GIDNO00000000003333</global_id>"
|
||||
+ " <service_id>ELINKSVC01</service_id>"
|
||||
+ " <service_cmt>ELINK TEST Service</service_cmt>"
|
||||
+ " <service_tn>S</service_tn>"
|
||||
+ " <Session_id>SESSIONID001</Session_id>"
|
||||
+ " <encrypt_yn>NO</encrypt_yn>"
|
||||
+ " <http_url></http_url>"
|
||||
+ " <screen_id>SCREEN0000001</screen_id>"
|
||||
+ " <scr_no>000000000100000000020000000003</scr_no>"
|
||||
+ " <scr_dsc></scr_dsc>"
|
||||
+ " <usr_id>USER000001</usr_id>"
|
||||
+ " <ip_addr></ip_addr>"
|
||||
+ " <ip_mac></ip_mac>"
|
||||
+ " <com_code>EACT</com_code>"
|
||||
+ " <head_code>EACT001</head_code>"
|
||||
+ " <dept_cd>ELINK01</dept_cd>"
|
||||
+ " <conn_tp>CH</conn_tp>"
|
||||
+ " <Inter_chn>EA</Inter_chn>"
|
||||
+ " <recv_tm>20220928000000000</recv_tm>"
|
||||
+ " <send_tm></send_tm>"
|
||||
+ " <return_gubun>S</return_gubun>"
|
||||
+ " <return_value></return_value>"
|
||||
+ " <msg_id></msg_id>"
|
||||
+ " <msg_nm></msg_nm>"
|
||||
+ " <filler></filler>"
|
||||
+ " <bizData><message><bizfield1>BIZ1</bizfield1><bizfield2>BIZ2</bizfield2><bizfield3>BIZ3</bizfield3></message></bizData>"
|
||||
+ "</Root>";
|
||||
|
||||
public SrandardMessageTest() {
|
||||
|
||||
}
|
||||
|
||||
public static StandardMessage generateMessage() {
|
||||
// return StandardMessageUtil.generateMessageFromCCsvFile();
|
||||
StandardMessageManager manager = StandardMessageManager.getInstance();
|
||||
try {
|
||||
manager.init();
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return manager.getStandardMessage();
|
||||
}
|
||||
|
||||
|
||||
public static StandardMessage generateMessageFromItemList() {
|
||||
// Test generator from List definition (with default values)
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
logger.debug(">> Test generator from List definition ( with default values)");
|
||||
ArrayList<StandardItem> list = new ArrayList<StandardItem>();
|
||||
StandardItem group = null;
|
||||
StandardItem item = null;
|
||||
group = new StandardItem("Header", 1, StandardType.GROUP, 1, 0, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("StndCicsTrncd", 2, StandardType.FIELD, 1, 10, 0, "");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndIntnlStndTelgmLen", 2, StandardType.FIELD, 1, 10, 1, "0");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndTranBaseYmd", 2, StandardType.FIELD, 1, 10, 0, "");
|
||||
list.add(item);
|
||||
|
||||
StandardItem group1 = new StandardItem("Common", 1, StandardType.GROUP, 0, 0, null);
|
||||
list.add(group1);
|
||||
group = new StandardItem("TranInfo", 2, StandardType.GROUP, 0, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("StndCicsTrncd", 3, StandardType.FIELD, 3, 0, "KB0");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndTelgmRecvTranCd", 3, StandardType.FIELD, 10, 0, "");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndPrcssRtdTranCd", 3, StandardType.FIELD, 10, 0, "");
|
||||
list.add(item);
|
||||
|
||||
group = new StandardItem("Array", 1, StandardType.GRID, 3, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("Item1", 2, StandardType.FIELD, 10, 0, "JI6H");
|
||||
list.add(item);
|
||||
item = new StandardItem("Group", 2, StandardType.GRID, 1, 0, null);
|
||||
list.add(item);
|
||||
item = new StandardItem("gitem1", 3, StandardType.FIELD, 10, 1, "726");
|
||||
list.add(item);
|
||||
item = new StandardItem("gitem2", 3, StandardType.FIELD, 10, 0, "20220905");
|
||||
list.add(item);
|
||||
|
||||
item = new StandardItem("bizData", 1, StandardType.BIZDATA, 0, 0, null);
|
||||
list.add(item);
|
||||
|
||||
StandardMessage message = null;;
|
||||
try {
|
||||
message = StandardMessageUtil.generate(list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// 1. CSV -> List -> gen
|
||||
// 2. XML -> List -> gen
|
||||
// 3. JSON -> List -> gen
|
||||
logger.debug("@toCSVString\n" + message.toCSVString());
|
||||
logger.debug("@toString\n" + message.toString());
|
||||
logger.debug("@toJson\n" + message.toJson());
|
||||
|
||||
// Test initialize getter
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
logger.debug(">> Test initialize getter");
|
||||
String findItem = "StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Header.StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Common.TranInfo.StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
logger.debug(">> Test file item with path & set value");
|
||||
StandardItem it = message.findItem(findItem);
|
||||
if(it !=null) {
|
||||
it.setValue("changed!");
|
||||
}
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Common.TranInfo.StndCicsTrncd1";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Array[0].Group.gitem2";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Array[0]";
|
||||
logger.debug(findItem + " => " +message.findItem(findItem));
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void testJsonReader() throws Exception {
|
||||
StandardMessage message = null;;
|
||||
message = generateMessage();
|
||||
if(message == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(">> Test Json Parsing");
|
||||
|
||||
logger.debug("jsonString = " +jsonString);
|
||||
|
||||
// Test Json parsing
|
||||
// StandardReader jsonReader = new JsonReader();
|
||||
|
||||
// Test Dynamic Loading
|
||||
StandardReader reader = null;
|
||||
String readerName = "com.eactive.eai.message.parser.JsonReader";
|
||||
Class cl = null;
|
||||
try {
|
||||
cl = Class.forName(readerName);
|
||||
reader = (StandardReader)cl.newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
reader.parse(message, jsonString);
|
||||
|
||||
String charset = "utf-8";
|
||||
message.setBizDataCharset(charset);
|
||||
logger.debug(">> message=\n" + message);
|
||||
logger.debug(">> message.toJson()=\n" + message.toJson());
|
||||
logger.debug(">> message.toJson(false)=\n" + message.toJson(false));
|
||||
logger.debug(">> message.toPrettyJson()=\n" + message.toPrettyJson());
|
||||
logger.debug(">> message.toPrettyJson(false)=\n" + message.toPrettyJson(false));
|
||||
logger.debug(">> message.toXML()=\n" + message.toXML());
|
||||
logger.debug(">> message.toPrettyXML()=\n" + message.toPrettyXML());
|
||||
logger.debug(">> message.toFixedString()=\n[" + message.toFixedString(charset)+"]");
|
||||
logger.debug(">> message.toByteArray()=\n[" + new String(message.toByteArray(charset)) + "]");
|
||||
logger.debug(">> message.toLogList()=\n" + message.toLogList());
|
||||
// Test getter after parsing
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
String findItem = null;
|
||||
logger.debug(">> Test getter after parsing");
|
||||
findItem = "global_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "Session_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "screen_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "recv_tm";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
}
|
||||
|
||||
public static void testXmlReader() throws Exception {
|
||||
StandardMessage message = null;;
|
||||
message = generateMessage();
|
||||
if(message == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(">> Test Json Parsing");
|
||||
|
||||
logger.debug("xmlString = " + xmlString);
|
||||
|
||||
// Test XML parsing
|
||||
StandardReader reader = new XmlReader();
|
||||
reader.parse(message, xmlString);
|
||||
|
||||
logger.debug(">> message=\n" + message);
|
||||
logger.debug(">> message.toJson()=\n" + message.toJson());
|
||||
logger.debug(">> message.toXML()=\n" + message.toXML());
|
||||
// Test getter after parsing
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
String findItem = null;
|
||||
logger.debug(">> Test getter after parsing");
|
||||
findItem = "global_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "Session_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "screen_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "recv_tm";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
}
|
||||
|
||||
|
||||
public static void testDynamicReader(String messageType, String messageString) throws Exception {
|
||||
StandardMessage message = null;
|
||||
message = generateMessage();
|
||||
if(message == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
logger.debug(">> Test Parsing");
|
||||
|
||||
logger.debug("messageString = " +messageString);
|
||||
|
||||
// Test Json parsing
|
||||
// Test Dynamic Loading
|
||||
StandardReader reader = null;
|
||||
|
||||
StandardMessageManager manager = StandardMessageManager.getInstance();
|
||||
|
||||
reader = manager.getReader(messageType);
|
||||
|
||||
reader.parse(message, messageString);
|
||||
|
||||
String charset = "utf-8";
|
||||
|
||||
logger.debug(">> message=\n" + message);
|
||||
logger.debug(">> message.toByteArray()=\n" + new String(message.toByteArray(charset)));
|
||||
logger.debug(">> message.toJson()=\n" + message.toJson());
|
||||
logger.debug(">> message.toPrettyJson()=\n" + message.toPrettyJson());
|
||||
logger.debug(">> message.toXML()=\n" + message.toXML());
|
||||
logger.debug(">> message.toPrettyXML()=\n" + message.toPrettyXML());
|
||||
|
||||
logger.debug(">> message.setBizData() to TESTSET-DATA");
|
||||
message.setBizData("TESTSET-DATA", "utf-8");
|
||||
logger.debug(">> message.toByteArray()=\n[" + new String(message.toByteArray(charset)) +"]");
|
||||
// Test getter after parsing
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
String findItem = null;
|
||||
logger.debug(">> Test getter after parsing");
|
||||
findItem = "global_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "Session_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "screen_id";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
findItem = "recv_tm";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
}
|
||||
|
||||
public static void testSimple() {
|
||||
int level = 0;
|
||||
StandardMessage message = new StandardMessage();
|
||||
StandardItem group = null;
|
||||
StandardItem item = null;
|
||||
level++;
|
||||
group = new StandardItem("Header", level, 2, 0, 0, null);
|
||||
level++;
|
||||
item = new StandardItem("StndCicsTrncd", level, 1, 10, 0, "JI6H");
|
||||
group.addItem(item);
|
||||
item = new StandardItem("StndIntnlStndTelgmLen", level, 1, 10, 1, "726");
|
||||
group.addItem(item);
|
||||
item = new StandardItem("StndTranBaseYmd", level, 1, 10, 0, "20220905");
|
||||
group.addItem(item);
|
||||
message.addItem(group);
|
||||
|
||||
level--;
|
||||
StandardItem group1 = new StandardItem("Common", level, 2, 0, 0, null);
|
||||
level++;
|
||||
group = new StandardItem("TranInfo", level, 2, 0, 0, null);
|
||||
level++;
|
||||
item = new StandardItem("StndCicsTrncd", level, 1, 10, 0, "KB0");
|
||||
group.addItem(item);
|
||||
item = new StandardItem("StndTelgmRecvTranCd", level, 1, 10, 0, "EDU0100101");
|
||||
group.addItem(item);
|
||||
item = new StandardItem("StndPrcssRtdTranCd", level, 1, 10, 0, "JI6HWSE02002");
|
||||
group.addItem(item);
|
||||
group1.addItem(group);
|
||||
message.addItem(group1);
|
||||
|
||||
logger.debug(">> toString");
|
||||
logger.debug(message.toString());
|
||||
logger.debug(">> toCSVString");
|
||||
logger.debug(message.toCSVString());
|
||||
logger.debug(">> toJson");
|
||||
logger.debug(message.toJson());
|
||||
|
||||
String findItem = "StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Header.StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Common.TranInfo.StndCicsTrncd";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
|
||||
findItem = "Common.TranInfo.StndCicsTrncd1";
|
||||
logger.debug(findItem + " => " +message.findItemValue(findItem));
|
||||
}
|
||||
|
||||
public static void splitTest(String path, String pathSeparator) {
|
||||
String[] paths = null;
|
||||
logger.debug("path=" + path);
|
||||
logger.debug("pathSeparator=" + pathSeparator);
|
||||
|
||||
paths = path.split("[" + pathSeparator +"]");
|
||||
int index =0;
|
||||
for(String p: paths) {
|
||||
System.out.printf("path[%d]=(%s)\n", index++, p);
|
||||
}
|
||||
}
|
||||
|
||||
public static void testFlatReader( int caseNumber) {
|
||||
String testString = null;
|
||||
|
||||
if( caseNumber == 1) {
|
||||
testString ="000199GIDNO00000000004444 ELINKSVC01ELINK TEST Service SSESSIONID001 NO SCREEN0000001000000000100000000020000000003 USER000001 EACTEACT001ELINK01CHEA20220928000000000 S @@";
|
||||
try {
|
||||
testDynamicReader("FLAT", testString);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.debug("success test : " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// underflow
|
||||
if( caseNumber == 2) {
|
||||
testString ="000199GIDNO00000000004444 ELINKSVC01ELINK TEST Service SSESSIONID001 NO SCREEN0000001000000000100000000020000000003 USER000001 EACTEACT001ELINK01CHEA20220928000000000 S @@";
|
||||
try {
|
||||
testDynamicReader("FLAT", testString);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.debug("underflow test : " + ex.toString());
|
||||
}
|
||||
}
|
||||
// with bizData
|
||||
if( caseNumber == 3) {
|
||||
testString ="001005GIDNO00000000004444 ELINKSVC01ELINK TEST Service SSESSIONID001 NO SCREEN0000001000000000100000000020000000003 USER000001 EACTEACT001ELINK01CHEA20220928000000000 S ADDED@@";
|
||||
try {
|
||||
testDynamicReader("FLAT", testString);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
logger.debug("overflow test : " + ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// testSimple();
|
||||
|
||||
// testJsonReader();
|
||||
// testXmlReader();
|
||||
testFlatReader(1);
|
||||
// testFlatReader(2);
|
||||
// testFlatReader(3);
|
||||
|
||||
// testDynamicReader("JSON", jsonString);
|
||||
// testDynamicReader("XML", xmlString);
|
||||
// generateMessageFromItemList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.eactive.eai.message.test;
|
||||
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.service.DefaultInterfaceMapper;
|
||||
|
||||
public class TestInterfaceMapper extends DefaultInterfaceMapper {
|
||||
public TestInterfaceMapper() {
|
||||
|
||||
}
|
||||
//------------------------------------------------------------
|
||||
// 재정의가 필요한 항목에 대한 로직 추가
|
||||
//------------------------------------------------------------
|
||||
@Override
|
||||
public String getEaiSvcCode(StandardMessage standardMessage) {
|
||||
String eaiSvcCode = null;
|
||||
String cicsTranCd = getServiceId(standardMessage);
|
||||
// TODO : site에 맞게 조합해야 함.
|
||||
eaiSvcCode = cicsTranCd +"S01";
|
||||
return eaiSvcCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.eactive.eai.message.test;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.eactive.eai.message.StandardDataType;
|
||||
import com.eactive.eai.message.StandardItem;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.StandardMessageUtil;
|
||||
import com.eactive.eai.message.StandardType;
|
||||
import com.eactive.eai.message.mapper.DefaultMessageMapper;
|
||||
import com.eactive.eai.message.mapper.MessageMapper;
|
||||
|
||||
public class VersionMappingTest {
|
||||
static Logger logger = LoggerFactory.getLogger(VersionMappingTest.class);
|
||||
|
||||
public VersionMappingTest() {
|
||||
|
||||
}
|
||||
|
||||
public static StandardMessage generateMessageFromItemList() {
|
||||
// Test generator from List definition (with default values)
|
||||
logger.debug("\n>> ----------------------------------------------------------------------------------");
|
||||
logger.debug(">> Test generator from List definition ( with default values)");
|
||||
ArrayList<StandardItem> list = new ArrayList<StandardItem>();
|
||||
StandardItem group = null;
|
||||
StandardItem item = null;
|
||||
group = new StandardItem("Header", 1, StandardType.GROUP, 1, 0, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("StndCicsTrncd", 2, StandardType.FIELD, 1, 10, StandardDataType.STRING, "");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndIntnlStndTelgmLen", 2, StandardType.FIELD, 1, 10, StandardDataType.LL_NUMBER, "0");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndTranBaseYmd", 2, StandardType.FIELD, 1, 10, StandardDataType.STRING, "");
|
||||
list.add(item);
|
||||
|
||||
StandardItem group1 = new StandardItem("Common", 1, StandardType.GROUP, 0, 0, null);
|
||||
list.add(group1);
|
||||
group = new StandardItem("TranInfo", 2, StandardType.GROUP, 0, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("StndCicsTrncd", 3, StandardType.FIELD, 3, StandardDataType.STRING, "KB0");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndTelgmRecvTranCd", 3, StandardType.FIELD, 10, StandardDataType.STRING, "");
|
||||
list.add(item);
|
||||
item = new StandardItem("StndPrcssRtdTranCd", 3, StandardType.FIELD, 10, StandardDataType.STRING, "");
|
||||
list.add(item);
|
||||
|
||||
group = new StandardItem("Array", 1, StandardType.GRID, 3, 0, null);
|
||||
list.add(group);
|
||||
item = new StandardItem("Item1", 2, StandardType.FIELD, 10, StandardDataType.STRING, "JI6H");
|
||||
list.add(item);
|
||||
item = new StandardItem("Group", 2, StandardType.GRID, 1, StandardDataType.STRING, null);
|
||||
list.add(item);
|
||||
item = new StandardItem("gitem1", 3, StandardType.FIELD, 10, StandardDataType.STRING, "726");
|
||||
list.add(item);
|
||||
item = new StandardItem("gitem2", 3, StandardType.FIELD, 10, StandardDataType.STRING, "20220905");
|
||||
list.add(item);
|
||||
|
||||
item = new StandardItem("bizData", 1, StandardType.BIZDATA, 0, StandardDataType.STRING, null);
|
||||
list.add(item);
|
||||
|
||||
StandardMessage message = null;;
|
||||
try {
|
||||
message = StandardMessageUtil.generate(list);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
logger.debug("@toJson\n" + message.toJson());
|
||||
|
||||
MessageMapper mapper = new DefaultMessageMapper();
|
||||
String targetPath = "Header.StndCicsTrncd";
|
||||
String sourcePath = "Common.TranInfo.StndCicsTrncd";
|
||||
mapper.map(message, sourcePath, message, targetPath);
|
||||
logger.debug("@toJson\n" + message.toJson());
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
generateMessageFromItemList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.eactive.eai.util.jsonJson;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.eactive.eai.util.json.JsonPathsTransform;
|
||||
import com.eactive.eai.util.json.transformer.CustomValueTransformer;
|
||||
import com.eactive.eai.util.json.transformer.ValueTransformer;
|
||||
|
||||
public class PathsTransformTest {
|
||||
public static void main(String[] args) {
|
||||
String jsonString = "{ \"person\": { \"name\": \"John\", \"age\": 30, \"groups\": [ { \"id\": 1, \"name\": \"Group A\" }, { \"id\": 2, \"name\": \"Group B\" }, { \"id\": 3, \"name\": \"Group C\" } ] } }";
|
||||
|
||||
System.out.println("Origin JSON): \n" + jsonString);
|
||||
|
||||
// CustomValueTransformer 사용 예제
|
||||
CustomValueTransformer nameTransformer = new CustomValueTransformer();
|
||||
nameTransformer.setProperty("PREFIX", "Mr. ");
|
||||
nameTransformer.setProperty("SUFFIX", " Esq.");
|
||||
|
||||
CustomValueTransformer groupTransformer = new CustomValueTransformer();
|
||||
groupTransformer.setProperty("PREFIX", "Team: ");
|
||||
groupTransformer.setProperty("SUFFIX", " Ltd.");
|
||||
|
||||
// 타입에따라 각각 처리하도록 해야 한다.
|
||||
Map<String, ValueTransformer<String, String>> pathTransformerMap = new HashMap<>();
|
||||
pathTransformerMap.put("$.person.name", nameTransformer); // 경로: person.name
|
||||
pathTransformerMap.put("$.person.groups[0].name", groupTransformer); // 경로: groups[0].name
|
||||
pathTransformerMap.put("$.person.groups[1].name", groupTransformer); // 경로: groups[1].name
|
||||
pathTransformerMap.put("$.person.groups[2].name", groupTransformer); // 경로: groups[2].name
|
||||
|
||||
String modifiedJsonString = JsonPathsTransform.modifyValuesAtPaths(jsonString, pathTransformerMap, true);
|
||||
System.out.println("Modified JSON (Pretty): \n" + modifiedJsonString);
|
||||
|
||||
Map<String, ValueTransformer<Integer, Integer>> intTransformerMap = new HashMap<>();
|
||||
intTransformerMap.put("$.person.age", new ValueTransformer<Integer, Integer>() {
|
||||
@Override
|
||||
public Integer transform(Integer age) {
|
||||
return age + 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String propertyName, Object value) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public String getProperty(String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
modifiedJsonString = JsonPathsTransform.modifyValuesAtPaths(jsonString, intTransformerMap, true);
|
||||
System.out.println("Modified JSON (Pretty): \n" + modifiedJsonString);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.eactive.eai.util.jsonJson;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.eactive.eai.util.json.JsonPathsTransform;
|
||||
import com.eactive.eai.util.json.JsonSimplePathsTransform;
|
||||
import com.eactive.eai.util.json.transformer.CustomValueTransformer;
|
||||
import com.eactive.eai.util.json.transformer.ValueTransformer;
|
||||
|
||||
public class SimplePathsTransformTest {
|
||||
public static void main(String[] args) {
|
||||
String jsonString = "{ \"person\": { \"name\": \"John\", \"age\": 30, \"groups\": [ { \"id\": 1, \"name\": \"Group A\" }, { \"id\": 2, \"name\": \"Group B\" }, { \"id\": 3, \"name\": \"Group C\" } ] } }";
|
||||
|
||||
System.out.println("Origin JSON): \n" + jsonString);
|
||||
|
||||
// CustomValueTransformer 사용 예제
|
||||
CustomValueTransformer nameTransformer = new CustomValueTransformer();
|
||||
nameTransformer.setProperty("PREFIX", "Mr. ");
|
||||
nameTransformer.setProperty("SUFFIX", " Esq.");
|
||||
|
||||
CustomValueTransformer groupTransformer = new CustomValueTransformer();
|
||||
groupTransformer.setProperty("PREFIX", "Team: ");
|
||||
groupTransformer.setProperty("SUFFIX", " Ltd.");
|
||||
|
||||
// 타입에따라 각각 처리하도록 해야 한다.
|
||||
Map<String, ValueTransformer<String, String>> pathTransformerMap = new HashMap<>();
|
||||
pathTransformerMap.put("/person/name", nameTransformer);
|
||||
pathTransformerMap.put("/person/groups/0/name", groupTransformer);
|
||||
pathTransformerMap.put("/person/groups/1/name", groupTransformer);
|
||||
pathTransformerMap.put("/person/groups/2/name", groupTransformer);
|
||||
|
||||
String modifiedJsonString = JsonSimplePathsTransform.modifyValuesAtPaths(jsonString, pathTransformerMap, true);
|
||||
System.out.println("Modified JSON (Pretty): \n" + modifiedJsonString);
|
||||
|
||||
Map<String, ValueTransformer<Integer, Integer>> intTransformerMap = new HashMap<>();
|
||||
intTransformerMap.put("/person/age", new ValueTransformer<Integer, Integer>() {
|
||||
@Override
|
||||
public Integer transform(Integer age) {
|
||||
return age + 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(String propertyName, Object value) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
@Override
|
||||
public String getProperty(String propertyName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
modifiedJsonString = JsonSimplePathsTransform.modifyValuesAtPaths(jsonString, intTransformerMap, true);
|
||||
System.out.println("Modified JSON (Pretty): \n" + modifiedJsonString);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.eactive.kakao.rolling.impl;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.hibernate.tool.schema.TargetType;
|
||||
|
||||
import com.eactive.kakao.rolling.CurrentCommitId;
|
||||
import com.eactive.kakao.rolling.RollingSuffix;
|
||||
|
||||
public class SchemaGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
|
||||
// .applySetting("hibernate.dialect", "org.hibernate.dialect.Oracle10gDialect")
|
||||
.applySetting("hibernate.dialect", "org.hibernate.dialect.PostgreSQL10Dialect")
|
||||
.build();
|
||||
|
||||
MetadataSources metadata = new MetadataSources(registry);
|
||||
|
||||
// 엔티티 클래스 추가
|
||||
metadata.addAnnotatedClass(RollingSuffix.class);
|
||||
// rolling_suffix
|
||||
metadata.addAnnotatedClass(CurrentCommitId.class);
|
||||
|
||||
SchemaExport export = new SchemaExport();
|
||||
export.setFormat(true);
|
||||
export.setOutputFile("build/create.sql");
|
||||
export.createOnly(EnumSet.of(TargetType.SCRIPT), metadata.buildMetadata());
|
||||
|
||||
StandardServiceRegistryBuilder.destroy(registry);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user