Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.bo.test.delivery.tolerance;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.BusinessTransaction;
- import org.jleaf.core.CoreException;
- import org.jleaf.core.Dto;
- import org.jleaf.core.GeneralConstants;
- import org.jleaf.core.test.AbstractSpringDbUnitTest;
- import org.jleaf.erp.master.MasterExceptionConstantsForDlg;
- import org.jleaf.erp.master.bo.test.product.TestAddPurchasePriceProduct;
- import org.junit.Assert;
- 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 TestAddDeliveryTolerance extends AbstractSpringDbUnitTest {
- private static final Logger log = LoggerFactory
- .getLogger(TestAddDeliveryTolerance.class);
- @Autowired
- @Qualifier("addDeliveryTolerance")
- private BusinessTransaction addDeliveryTolerance;
- @Autowired
- @Qualifier("isDeliveryToleranceExistsByIndex")
- private BusinessFunction isDeliveryToleranceExistsByIndex;
- @Autowired
- @Qualifier("findDeliveryToleranceById")
- private BusinessFunction findDeliveryToleranceById;
- @Before
- public void prepareData(){
- super.deleteFromTables("m_delivery_tolerance", "m_city", "m_warehouse");
- super.executeSqlScript("scripts/TestAddDeliveryTolerance.sql", true);
- }
- /**
- * Test Add Delivery Tolerance
- *
- * @author Henokh Marjie Rivaldy, September 13, 2016
- * @throws Exception
- *
- */
- @Test
- public void testAddDeliveryTolerance() throws Exception{
- Dto input = new Dto();
- input.put("tenantLoginId",10L);
- input.put("roleLoginId",10L);
- input.put("userLoginId",999L);
- input.put("datetime","20160815000000");
- input.put("warehouseFromId",122L);
- input.put("cityToId",898L);
- input.put("tolerance",7L);
- input.put("active","Y");
- Dto output = addDeliveryTolerance.execute(input);
- Long id = output.getLong("id");
- Dto deliveryToleranceDto = findDeliveryToleranceById.execute(new Dto().put("id", id));
- log.debug("deliveryToleranceDto : "+deliveryToleranceDto);
- Assert.assertEquals(10L, deliveryToleranceDto.getLong("tenantId").longValue());
- Assert.assertEquals(7L, deliveryToleranceDto.getLong("tolerance").longValue());
- Assert.assertEquals(122L, deliveryToleranceDto.getLong("warehouseFromId").longValue());
- Assert.assertEquals(898L, deliveryToleranceDto.getLong("cityToId").longValue());
- }
- @Test
- public void testAddDeliveryToleranceTapiBukanDeliveryTolerance()
- throws Exception {
- Dto input = new Dto();
- input.put("tenantLoginId",10L);
- input.put("roleLoginId",10L);
- input.put("userLoginId",12L);
- input.put("datetime","20160809000000");
- input.put("warehouseFromId",2L);
- input.put("cityToId",5L);
- input.put("tolerance",2L);
- input.put("active","Y");
- try {
- Dto output = addDeliveryTolerance.execute(input);
- Long id = output.getLong("id");
- Dto deliveryToleranceDto = findDeliveryToleranceById.execute(new Dto().put("id", id));
- log.debug("deliveryToleranceDto : "+deliveryToleranceDto);
- Assert.assertEquals(10L, deliveryToleranceDto.getLong("tenantId").longValue());
- Assert.assertEquals(2L, deliveryToleranceDto.getLong("tolerance").longValue());
- Assert.assertEquals(2L, deliveryToleranceDto.getLong("warehouseFromId").longValue());
- Assert.assertEquals(5L, deliveryToleranceDto.getLong("cityToId").longValue());
- Assert.fail("Validasi group partner gagal");
- } catch (CoreException e) {
- // untuk masuk ke core exception
- log.debug("Masuk core exception");
- Assert.assertEquals(
- MasterExceptionConstantsForDlg.DELIVERY_TOLERANCE_ALREADY_EXISTS,
- e.getErrorKey());
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment