Fanadia_Friska

BF TESTGET FIX

Aug 31st, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.23 KB | None | 0 0
  1. package org.jleaf.pos2.test.vehicle;
  2.  
  3. import java.util.List;
  4.  
  5. import junit.framework.Assert;
  6.  
  7. import org.jleaf.core.BusinessFunction;
  8. import org.jleaf.core.CoreException;
  9. import org.jleaf.core.Dto;
  10. import org.jleaf.core.test.AbstractSpringDbUnitTest;
  11. import org.junit.Before;
  12. import org.junit.Test;
  13. import org.junit.runner.RunWith;
  14. import org.slf4j.Logger;
  15. import org.slf4j.LoggerFactory;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Qualifier;
  18. import org.springframework.test.context.ContextConfiguration;
  19. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  20. import org.springframework.test.context.transaction.TransactionConfiguration;
  21. import org.springframework.transaction.annotation.Transactional;
  22.  
  23. @RunWith(SpringJUnit4ClassRunner.class)
  24. @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
  25. @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
  26. @Transactional
  27. public class TestGetVehicleList extends AbstractSpringDbUnitTest {
  28. private static final Logger log = LoggerFactory
  29. .getLogger(TestGetVehicleList.class);
  30.  
  31. // private static final Logger log = LoggerFactory
  32. // .getLogger(NamaTestClassMu.class);
  33.  
  34. @Autowired
  35. @Qualifier("getVehicleList")
  36. private BusinessFunction getVehicleList;
  37.  
  38. @Before
  39. public void prepareData() {
  40. super.deleteFromTables("m_vehicle", "m_vehicle_group", "m_vehicle_type");
  41. super.executeSqlScript("scripts/TestGetVehicleList.sql", false);
  42. }
  43.  
  44. @SuppressWarnings("unchecked")
  45. @Test
  46. public void testGetVehicleListIfKeywordByOwnerNameAndActiveYes()
  47. throws Exception {
  48.  
  49. Dto input = new Dto();
  50. input.put("keyword", "Mail");
  51. input.put("limit", 1L);
  52. input.put("offset", 0L);
  53. input.put("active", "Y");
  54. log.debug("input>>>>>>" + input);
  55.  
  56. try {
  57.  
  58. Dto result = getVehicleList.execute(input);
  59.  
  60. List<Dto> list = result.getList("vehicleList");
  61.  
  62. log.debug("Output bf get vehicle :" + result);
  63.  
  64. Assert.assertEquals(1, list.size());
  65.  
  66. } catch (CoreException e) {
  67. e.printStackTrace();
  68. Assert.fail(e.getMessage());
  69. }
  70.  
  71. }
  72.  
  73. @SuppressWarnings("unchecked")
  74. @Test
  75. public void TestGetListIfKeywordBylicenseNoAndActiveYes() throws Exception {
  76.  
  77. Dto input = new Dto();
  78. input.put("keyword", "H 6634 SS");
  79. input.put("limit", 7L);
  80. input.put("offset", 0L);
  81. input.put("active", "Y");
  82.  
  83. try {
  84.  
  85. Dto result = getVehicleList.execute(input);
  86.  
  87. List<Dto> list = result.getList("vehicleList");
  88.  
  89. log.debug("List :" + result.getList("vehicleList"));
  90.  
  91. Assert.assertEquals(1, list.size());
  92. } catch (CoreException e) {
  93. e.printStackTrace();
  94.  
  95. Assert.fail(e.getMessage());
  96. }
  97.  
  98. }
  99.  
  100. @SuppressWarnings("unchecked")
  101. @Test
  102. public void testGetListIfKeywordBycustomerNameAndActiveYes() throws Exception {
  103.  
  104. Dto input = new Dto();
  105. input.put("keyword", "Rika");
  106. input.put("limit", 1L);
  107. input.put("offset", 0L);
  108. input.put("active", "Y");
  109.  
  110. try {
  111.  
  112. Dto result = getVehicleList.execute(input);
  113.  
  114. List<Dto> list = result.getList("vehicleList");
  115.  
  116. log.debug("List :" + result.getList("vehicleList"));
  117.  
  118. Assert.assertEquals(1, list.size());
  119.  
  120. } catch (CoreException e) {
  121. e.printStackTrace();
  122. Assert.fail(e.getMessage());
  123. }
  124.  
  125. }
  126.  
  127. @SuppressWarnings("unchecked")
  128. @Test
  129. public void testGetListIfKeywordByownerNameAndActiveNo() throws Exception {
  130.  
  131. Dto input = new Dto();
  132. input.put("keyword", "Mail");
  133. input.put("limit", 7L);
  134. input.put("offset", 0L);
  135. input.put("active", "N");
  136.  
  137. try {
  138.  
  139. Dto result = getVehicleList.execute(input);
  140.  
  141. List<Dto> list = result.getList("vehicleList");
  142.  
  143. log.debug("List : " + result.getList("vehicleList"));
  144.  
  145. Assert.assertEquals(0, list.size());
  146.  
  147. } catch (CoreException e) {
  148. e.printStackTrace();
  149.  
  150. Assert.fail(e.getMessage());
  151. }
  152.  
  153. }
  154.  
  155. @SuppressWarnings("unchecked")
  156. @Test
  157. public void testSuccessIfKeywordAndActiveEmpty() throws Exception {
  158.  
  159. Dto input = new Dto();
  160. input.put("keyword", "");
  161. input.put("limit", 0L);
  162. input.put("offset", 0L);
  163. input.put("active", "");
  164.  
  165. try {
  166.  
  167. Dto result = getVehicleList.execute(input);
  168.  
  169. List<Dto> list = result.getList("vehicleList");
  170.  
  171. log.debug("List :" + result.getList("vehicleList"));
  172.  
  173. Assert.assertEquals(0, list.size());
  174.  
  175. } catch (CoreException e) {
  176. e.printStackTrace();
  177. Assert.fail(e.getMessage());
  178. }
  179.  
  180. }
  181.  
  182. @SuppressWarnings("unchecked")
  183. @Test
  184. public void testSuccessIfKeywordByvehicleCodeAndActiveEmpty()
  185. throws Exception {
  186.  
  187. Dto input = new Dto();
  188. input.put("keyword", "SZY");
  189. input.put("limit", 15L);
  190. input.put("offset", 0L);
  191. input.put("active", "");
  192.  
  193. try {
  194.  
  195. Dto result = getVehicleList.execute(input);
  196.  
  197. List<Dto> list = result.getList("vehicleList");
  198.  
  199. log.debug("List : " + list);
  200. Assert.assertEquals(0, list.size());
  201.  
  202. } catch (Exception ex) {
  203. ex.printStackTrace();
  204. Assert.fail(ex.getMessage());
  205. }
  206. }
  207.  
  208. @SuppressWarnings("unchecked")
  209. @Test
  210. public void testSuccessIfKeywordByvehicleNameAndActiveEmpty() throws Exception {
  211. // IfKeywordByvehicleNameAndActiveEmpty
  212. Dto input = new Dto();
  213. input.put("keyword", "Hnd");
  214. input.put("limit", 15L);
  215. input.put("offset", 0L);
  216. input.put("active", "");
  217.  
  218. try {
  219.  
  220. Dto result = getVehicleList.execute(input);
  221.  
  222. List<Dto> list = result.getList("vehicleList");
  223.  
  224. log.debug("List : " + result.getList("vehicleList"));
  225.  
  226. Assert.assertEquals(0, list.size());
  227.  
  228. } catch (Exception ex) {
  229. ex.printStackTrace();
  230. Assert.fail(ex.getMessage());
  231. }
  232. }
  233.  
  234. @Test
  235. public void testSuccessIfKeywordHondaAndActiveEmpty() throws Exception {
  236.  
  237. Dto input = new Dto();
  238. input.put("keyword", "Honda");
  239. input.put("limit", 15L);
  240. input.put("offset", 0L);
  241. input.put("active", "");
  242.  
  243. try {
  244.  
  245. Dto result = getVehicleList.execute(input);
  246.  
  247. @SuppressWarnings("unchecked")
  248. List<Dto> list = result.getList("vehicleList");
  249.  
  250. log.debug("List : " + result.getList("vehicleList"));
  251.  
  252. Assert.assertEquals(0, list.size());
  253.  
  254. } catch (Exception ex) {
  255. ex.printStackTrace();
  256. Assert.fail(ex.getMessage());
  257. }
  258. }
  259.  
  260. @SuppressWarnings("unchecked")
  261. @Test
  262. public void testSuccessIfActiveIsYesAndKeywordIsEmpty() throws Exception {
  263.  
  264. Dto input = new Dto();
  265. input.put("keyword", "");
  266. input.put("limit", 0L);
  267. input.put("offset", 0L);
  268. input.put("active", "Y");
  269.  
  270. try {
  271.  
  272. Dto result = getVehicleList.execute(input);
  273.  
  274. List<Dto> list = result.getList("vehicleList");
  275.  
  276. log.debug("List : " + result.getList("vehicleList"));
  277.  
  278. Assert.assertEquals(0, list.size());
  279.  
  280. } catch (CoreException e) {
  281. e.printStackTrace();
  282. Assert.fail(e.getMessage());
  283. }
  284.  
  285. }
  286.  
  287. @SuppressWarnings("unchecked")
  288. @Test
  289. public void testIfKeywordNotExists() throws Exception {
  290.  
  291. Dto input = new Dto();
  292. input.put("keyword", "HND");
  293. input.put("limit", 15L);
  294. input.put("offset", 0L);
  295. input.put("active", "Y");
  296.  
  297. try {
  298.  
  299. Dto result = getVehicleList.execute(input);
  300.  
  301. List<Dto> list = result.getList("vehicleList");
  302. Assert.assertEquals(0, list.size());
  303. } catch (Exception ex) {
  304. ex.printStackTrace();
  305. Assert.fail(ex.getMessage());
  306. }
  307.  
  308. }
  309.  
  310. }
Advertisement
Add Comment
Please, Sign In to add comment