Fanadia_Friska

test add region customer yg di edit nadia

Sep 21st, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.83 KB | None | 0 0
  1. package org.jleaf.erp.master.bo.test.customer.vs.rayon;
  2.  
  3. import junit.framework.Assert;
  4.  
  5. import org.jleaf.core.BusinessFunction;
  6. import org.jleaf.core.BusinessTransaction;
  7. import org.jleaf.core.CoreException;
  8. import org.jleaf.core.Dto;
  9. import org.jleaf.core.test.AbstractSpringDbUnitTest;
  10. import org.jleaf.erp.master.MasterExceptionConstantsForDlg;
  11. import org.jleaf.util.DateUtil;
  12. import org.junit.Before;
  13. import org.junit.Test;
  14. import org.junit.runner.RunWith;
  15. import org.slf4j.Logger;
  16. import org.slf4j.LoggerFactory;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.beans.factory.annotation.Qualifier;
  19. import org.springframework.test.context.ContextConfiguration;
  20. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  21. import org.springframework.test.context.transaction.TransactionConfiguration;
  22. import org.springframework.transaction.annotation.Transactional;
  23.  
  24. @RunWith(SpringJUnit4ClassRunner.class)
  25. @ContextConfiguration(locations = { "classpath:applicationContext.xml" })
  26. @TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
  27. @Transactional
  28. public class TestAddRegionCustomer extends AbstractSpringDbUnitTest {
  29. private static final Logger log = LoggerFactory
  30. .getLogger(TestAddRegionCustomer.class);
  31.  
  32. @Autowired
  33. @Qualifier("addRegionCustomer")
  34. private BusinessTransaction addRegionCustomer;
  35.  
  36. @Autowired
  37. @Qualifier("findRegionCustomerByIndex")
  38. private BusinessFunction findRegionCustomerByIndex;
  39.  
  40. @Autowired
  41. @Qualifier("isRegionCustomerExistsByIndex")
  42. BusinessFunction isRegionCustomerExistsByIndex;
  43.  
  44. @Autowired
  45. @Qualifier("valRegionCustomerExistsById")
  46. BusinessFunction valRegionCustomerExistsById;
  47.  
  48. @Before
  49. public void prepareData() {
  50. super.deleteFromTables("m_region_customer", "m_region", "m_partner");
  51. super.executeSqlScript("scripts/TestAddRegionCustomer.sql", false);
  52. }
  53.  
  54. @Test
  55. public void testAddRegionCustomer() throws Exception {
  56. String datetime = DateUtil.dateTimeNow();
  57.  
  58. Dto input = new Dto();
  59.  
  60. input.put("id", 8L);
  61. input.put("tenantLoginId", 23L);
  62. input.put("roleLoginId", 0002L);
  63. input.put("userLoginId", 0001L);
  64. input.put("datetime", datetime);
  65.  
  66. input.put("regionId", 15000009L);
  67. input.put("customerId", 16000017L);
  68. input.put("createUserId", -9L);
  69. input.put("updateUserId", -9L);
  70. input.put("version", 0L);
  71.  
  72.  
  73.  
  74.  
  75. try {
  76. Dto output = addRegionCustomer.execute(input);
  77. log.debug("Hasil add " +output);
  78.  
  79. Assert.assertEquals(8L, output.getLong("id").longValue());
  80. Assert.assertEquals(23L, output.getLong("tenantLoginId")
  81. .longValue());
  82. Assert.assertEquals(0002L, output.getLong("roleLoginId").longValue());
  83. Assert.assertEquals(0001L, output.getLong("userLoginId").longValue());
  84. Assert.assertEquals(datetime, output.getString("datetime"));
  85.  
  86. Assert.assertEquals(15000009L, output.getLong("regionId")
  87. .longValue());
  88. Assert.assertEquals(16000017L, output
  89. .getLong("customerId").longValue());
  90. Assert.assertEquals(datetime,
  91. output.getString("createDateTime"));
  92. Assert.assertEquals(datetime,
  93. output.getString("updateDateTime"));
  94. Assert.assertEquals(-9L, output.getLong("createUserId")
  95. .longValue());
  96. Assert.assertEquals(-9L, output.getLong("updateUserId")
  97. .longValue());
  98. Assert.assertEquals(0L, output.getLong("version")
  99. .longValue());
  100.  
  101. }catch (Exception e) {
  102. log.error(e.getMessage(), e);
  103. }
  104.  
  105. }
  106.  
  107.  
  108. // @Test
  109. // public void testAddRegionCustomerTapiBukanRegionCustomer()
  110. // throws Exception {
  111. // String datetime = DateUtil.dateTimeNow();
  112. // Dto input = new Dto();
  113. //
  114. // input.put("tenantLoginId", 24);
  115. // input.put("roleLoginId", 0002);
  116. // input.put("userLoginId", 0001);
  117. // input.put("datetime", datetime);
  118. //
  119. // input.put("regionId", 15000009);
  120. // input.put("customerId", 16000017);
  121. //
  122. // try {
  123. // Dto output = addRegionCustomer.execute(input);
  124. // Long id = output.getLong("id");
  125. //
  126. // Dto regionCustomerDto = findRegionCustomerByIndex.execute(new
  127. // Dto().put("id", id));
  128. // log.debug("deliveryToleranceDto : "+regionCustomerDto);
  129. //
  130. // Assert.assertEquals(10L,
  131. // regionCustomerDto.getLong("tenantId").longValue());
  132. // Assert.assertEquals(2L,
  133. // regionCustomerDto.getLong("tolerance").longValue());
  134. // Assert.assertEquals(2L,
  135. // regionCustomerDto.getLong("regionId").longValue());
  136. // Assert.assertEquals(5L,
  137. // regionCustomerDto.getLong("customerId").longValue());
  138. // Assert.fail("Validasi group region gagal");
  139. // } catch (CoreException e) {
  140. // // untuk masuk ke core exception
  141. // log.debug("Masuk core exception");
  142. //
  143. // Assert.assertEquals(
  144. // MasterExceptionConstantsForDlg.REGION_CUSTOMER_ALREADY_EXISTS,
  145. // e.getErrorKey());
  146. //
  147. // } catch (Exception e) {
  148. // log.error(e.getMessage(), e);
  149. // }
  150. //
  151. // }
  152.  
  153. }
Advertisement
Add Comment
Please, Sign In to add comment