Fanadia_Friska

ini Test Add

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