Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.bo.test.customer.vs.rayon;
- import junit.framework.Assert;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.BusinessTransaction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.test.AbstractSpringDbUnitTest;
- import org.jleaf.erp.master.MasterExceptionConstantsForDlg;
- import org.jleaf.util.DateUtil;
- 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 TestAddRegionCustomer extends AbstractSpringDbUnitTest {
- private static final Logger log = LoggerFactory
- .getLogger(TestAddRegionCustomer.class);
- @Autowired
- @Qualifier("addRegionCustomer")
- private BusinessTransaction addRegionCustomer;
- @Autowired
- @Qualifier("findRegionCustomerByIndex")
- private BusinessFunction findRegionCustomerByIndex;
- @Autowired
- @Qualifier("isRegionCustomerExistsByIndex")
- BusinessFunction isRegionCustomerExistsByIndex;
- @Autowired
- @Qualifier("valRegionCustomerExistsById")
- BusinessFunction valRegionCustomerExistsById;
- @Before
- public void prepareData() {
- super.deleteFromTables("m_region_customer", "m_region", "m_partner");
- super.executeSqlScript("scripts/TestAddRegionCustomer.sql", false);
- }
- @Test
- public void testAddRegionCustomer() throws Exception {
- String datetime = DateUtil.dateTimeNow();
- Dto input = new Dto();
- input.put("id", 8L);
- input.put("tenantLoginId", 23L);
- input.put("roleLoginId", 0002L);
- input.put("userLoginId", 0001L);
- input.put("datetime", datetime);
- input.put("regionId", 15000009L);
- input.put("customerId", 16000017L);
- input.put("createUserId", -9L);
- input.put("updateUserId", -9L);
- input.put("version", 0L);
- try {
- Dto output = addRegionCustomer.execute(input);
- log.debug("Hasil add " +output);
- Assert.assertEquals(8L, output.getLong("id").longValue());
- Assert.assertEquals(23L, output.getLong("tenantLoginId")
- .longValue());
- Assert.assertEquals(0002L, output.getLong("roleLoginId").longValue());
- Assert.assertEquals(0001L, output.getLong("userLoginId").longValue());
- Assert.assertEquals(datetime, output.getString("datetime"));
- Assert.assertEquals(15000009L, output.getLong("regionId")
- .longValue());
- Assert.assertEquals(16000017L, output
- .getLong("customerId").longValue());
- Assert.assertEquals(datetime,
- output.getString("createDateTime"));
- Assert.assertEquals(datetime,
- output.getString("updateDateTime"));
- Assert.assertEquals(-9L, output.getLong("createUserId")
- .longValue());
- Assert.assertEquals(-9L, output.getLong("updateUserId")
- .longValue());
- Assert.assertEquals(0L, output.getLong("version")
- .longValue());
- }catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- // @Test
- // public void testAddRegionCustomerTapiBukanRegionCustomer()
- // throws Exception {
- // String datetime = DateUtil.dateTimeNow();
- // Dto input = new Dto();
- //
- // input.put("tenantLoginId", 24);
- // input.put("roleLoginId", 0002);
- // input.put("userLoginId", 0001);
- // input.put("datetime", datetime);
- //
- // input.put("regionId", 15000009);
- // input.put("customerId", 16000017);
- //
- // try {
- // Dto output = addRegionCustomer.execute(input);
- // Long id = output.getLong("id");
- //
- // Dto regionCustomerDto = findRegionCustomerByIndex.execute(new
- // Dto().put("id", id));
- // log.debug("deliveryToleranceDto : "+regionCustomerDto);
- //
- // Assert.assertEquals(10L,
- // regionCustomerDto.getLong("tenantId").longValue());
- // Assert.assertEquals(2L,
- // regionCustomerDto.getLong("tolerance").longValue());
- // Assert.assertEquals(2L,
- // regionCustomerDto.getLong("regionId").longValue());
- // Assert.assertEquals(5L,
- // regionCustomerDto.getLong("customerId").longValue());
- // Assert.fail("Validasi group region gagal");
- // } catch (CoreException e) {
- // // untuk masuk ke core exception
- // log.debug("Masuk core exception");
- //
- // Assert.assertEquals(
- // MasterExceptionConstantsForDlg.REGION_CUSTOMER_ALREADY_EXISTS,
- // e.getErrorKey());
- //
- // } catch (Exception e) {
- // log.error(e.getMessage(), e);
- // }
- //
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment