Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.pos2.test.vehicle;
- import java.util.List;
- import junit.framework.Assert;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.test.AbstractSpringDbUnitTest;
- import org.junit.Before;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Qualifier;
- import org.springframework.test.context.ContextConfiguration;
- import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
- import org.springframework.test.context.transaction.TransactionConfiguration;
- import org.springframework.transaction.annotation.Transactional;
- @RunWith(SpringJUnit4ClassRunner.class)
- @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
- @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
- @Transactional
- public class TestGetVehicleList extends AbstractSpringDbUnitTest {
- private static Logger log = LoggerFactory
- .getLogger(TestGetVehicleList.class);
- @Autowired
- @Qualifier("getVehicleList")
- private BusinessFunction getVehicleList;
- @Before
- public void prepareData() {
- super.deleteFromTables("m_vehicle", "m_vehicle_group", "m_vehicle_type");
- super.executeSqlScript("scripts/TestGetVehicleList.sql", false);
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testGetListIfKeywordByVehicleCodeAndActiveYes()
- throws Exception {
- Dto input = new Dto();
- input.put("keyword","HND");
- input.put("limit", 1L);
- input.put("offset", 0L);
- input.put("active","Y");
- log.debug("input>>>>>>"+input);
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : " + list.size());
- Assert.assertEquals(1, list.size());
- } catch (CoreException e) {
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
- /* @SuppressWarnings("unchecked")
- @Test
- public void TestGetListIfKeywordByVehicleNameAndActiveYes() throws Exception {
- Dto input = new Dto();
- input.put("keyword", "HND");
- input.put("limit", 7L);
- input.put("offset", 0L);
- input.put("active", "Y");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : " + result.getList("vehicleList"));
- Assert.assertEquals(1, list.size());
- } catch (CoreException e) {
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testGetListIfKeywordByvehicleCodeAndActiveNo() throws
- Exception{
- Dto input = new Dto();
- input.put("keyword", "YMH");
- input.put("limit", 7L);
- input.put("offset", 0L);
- input.put("active", "n");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(0, list.size());
- }catch(CoreException e){
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testGetListIfKeywordByvehicleNameAndActiveNo() throws
- Exception{
- Dto input = new Dto();
- input.put("keyword", "HONDA");
- input.put("limit", 7L);
- input.put("offset", 0L);
- input.put("active", "y");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(0, list.size());
- }catch(CoreException e){
- e.printStackTrace();
- Assert.fail(e.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testSuccessIfKeywordAndActiveEmpty() throws Exception{
- Dto input = new Dto();
- input.put("keyword", "");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(3, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testSuccessIfKeywordByvehicleCodeAndActiveEmpty() throws
- Exception{
- Dto input = new Dto();
- input.put("keyword", "HND");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+list);
- Assert.assertEquals(0, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testSuccess() throws Exception{
- //IfKeywordByvehicleNameAndActiveEmpty
- Dto input = new Dto();
- input.put("keyword", "Hnd");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(1, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @Test
- public void testSuccessIfKeywordHondaAndActiveEmpty() throws Exception{
- Dto input = new Dto();
- input.put("keyword", "Hnd");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "");
- try {
- Dto result = getVehicleList.execute(input);
- @SuppressWarnings("unchecked")
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(1, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testSuccessIfActiveIsYesAndKeywordIsEmpty() throws Exception{
- Dto input = new Dto();
- input.put("keyword", "");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "y");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- log.debug("List : "+result.getList("vehicleList"));
- Assert.assertEquals(2, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testSuccessIfActiveIsNoAndKeywordIsEmpty() throws Exception{
- Dto input = new Dto();
- input.put("keyword", "");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "n");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- Assert.assertEquals(1, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- @SuppressWarnings("unchecked")
- @Test
- public void testIfKeywordNotExists() throws Exception{
- Dto input = new Dto();
- input.put("keyword", "SZY");
- input.put("limit", 15L);
- input.put("offset", 0L);
- input.put("active", "y");
- try {
- Dto result = getVehicleList.execute(input);
- List<Dto> list = result.getList("vehicleList");
- Assert.assertEquals(0, list.size());
- }catch(Exception ex){
- ex.printStackTrace();
- Assert.fail(ex.getMessage());
- }
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment