Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.jleaf.erp.master.bo.test.customer.vs.rayon;
- import java.util.List;
- import junit.framework.Assert;
- import org.jleaf.core.BusinessFunction;
- import org.jleaf.core.BusinessTransaction;
- import org.jleaf.core.Dto;
- import org.jleaf.core.GeneralConstants;
- import org.jleaf.core.test.AbstractSpringDbUnitTest;
- 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 TestGetRegionCustomerList extends AbstractSpringDbUnitTest {
- private static final Logger log = LoggerFactory
- .getLogger(TestGetRegionCustomerList.class);
- @Autowired
- @Qualifier("getRegionCustomerList")
- private BusinessFunction getRegionCustomerList;
- @Before
- public void prepareData() {
- super.deleteFromTables("m_region_customer", "m_region", "m_partner");
- super.executeSqlScript("scripts/TestGetRegionCustomerList.sql", false);
- }
- //region code, dan region_name kosong
- @Test
- public void Kasus1() throws Exception{
- Dto input = new Dto();
- input.put("tenantId", 10L);
- input.put("region_code", "");
- input.put("region_name", "");
- input.put("active", GeneralConstants.YES);
- input.put("limit", 10L);
- input.put("offset", 0L);
- try {
- Dto output = getRegionCustomerList.execute(input);
- log.debug("ini output:" + output);
- List<Dto> list = output.getList("regionCustomerList");
- Assert.assertEquals(2, list.size());
- for (int i = 0; i < list.size() - 1; i++) {
- Dto listDto = list.get(i);
- if (i == 0) {
- Assert.assertEquals("1", listDto.getString("id"));
- Assert.assertEquals(10L, listDto.getLong("tenantId")
- .longValue());
- Assert.assertEquals("1", listDto.getString("region_code"));
- Assert.assertEquals("SUMATERA",
- listDto.getString("region_name"));
- } else if (i == 1) {
- Assert.assertEquals("2", listDto.getString("id"));
- Assert.assertEquals(10L, listDto.getLong("tenantId")
- .longValue());
- Assert.assertEquals("10", listDto.getString("region_code"));
- Assert.assertEquals("10", listDto.getString("region_name"));
- }
- }
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- //region_name kosong
- @Test
- public void Kasus2() {
- Dto input = new Dto();
- input.put("tenantId", 10L);
- input.put("region_code", "1");
- input.put("region_name", "");
- input.put("active", GeneralConstants.YES);
- input.put("limit", 10L);
- input.put("offset", 0L);
- try {
- Dto output = getRegionCustomerList.execute(input);
- log.debug("ini output:" + output);
- List<Dto> list = output.getList("regionCustomerList");
- Dto listDto = list.get(0);
- Assert.assertEquals(1, list.size());
- Assert.assertEquals("1", listDto.getString("id"));
- Assert.assertEquals(10L, listDto.getLong("tenantId").longValue());
- Assert.assertEquals("1", listDto.getString("region_code"));
- Assert.assertEquals("SUMATERA", listDto.getString("region_name"));
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- //region_code kosong
- @Test
- public void Kasus3() {
- Dto input = new Dto();
- input.put("tenantId", 10L);
- input.put("region_code", "");
- input.put("region_name", "SUMATERA");
- input.put("active", GeneralConstants.YES);
- input.put("limit", 10L);
- input.put("offset", 0L);
- try {
- Dto output = getRegionCustomerList.execute(input);
- log.debug("ini output:" + output);
- List<Dto> list = output.getList("regionCustomerList");
- Dto listDto = list.get(0);
- Assert.assertEquals(1, list.size());
- Assert.assertEquals("1", listDto.getString("id"));
- Assert.assertEquals(10L, listDto.getLong("tenantId").longValue());
- Assert.assertEquals("1", listDto.getString("region_code"));
- Assert.assertEquals("SUMATERA", listDto.getString("region_name"));
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- //region_code dan region_name kosong dan active YES
- // @Test
- // public void Kasus4() {
- //
- // Dto input = new Dto();
- // input.put("tenantId", 10L);
- // input.put("region_code", "");
- // input.put("region_name", "");
- // input.put("active", GeneralConstants.YES);
- //
- // input.put("limit", 10L);
- // input.put("offset", 0L);
- //
- // try {
- // Dto output = getRegionCustomerList.execute(input);
- // log.debug("ini output:" + output);
- // List<Dto> list = output.getList("regionCustomerList");
- // // log.debug("Output bf get region customer :" + result);
- //
- // Dto listDto = list.get(0);
- // Assert.assertEquals(1, list.size());
- // Assert.assertEquals("1", listDto.getString("id"));
- // Assert.assertEquals(10L, listDto.getLong("tenantId").longValue());
- // Assert.assertEquals("1", listDto.getString("region_code"));
- // Assert.assertEquals("SUMATERA", listDto.getString("region_name"));
- //
- // } catch (Exception e) {
- // log.error(e.getMessage(), e);
- // }
- //
- // }
- //
- // //region_code kosong dan active NO
- // @Test
- // public void Kasus5() {
- //
- // Dto input = new Dto();
- // input.put("tenantId", 10L);
- // input.put("region_code", "");
- // input.put("region_name", "SUMATERA");
- // input.put("active", GeneralConstants.NO);
- //
- // input.put("limit", 10L);
- // input.put("offset", 0L);
- //
- // try {
- // Dto output = getRegionCustomerList.execute(input);
- // log.debug("ini output:" + output);
- // List<Dto> list = output.getList("regionCustomerList");
- //
- // Dto listDto = list.get(0);
- // Assert.assertEquals(1, list.size());
- // Assert.assertEquals("1", listDto.getString("id"));
- // Assert.assertEquals(10L, listDto.getLong("tenantId").longValue());
- // Assert.assertEquals("1", listDto.getString("region_code"));
- // Assert.assertEquals("SUMATERA", listDto.getString("region_name"));
- //
- // } catch (Exception e) {
- // log.error(e.getMessage(), e);
- // }
- //
- // }
- //
- // //region_code tidak ada di tabe , dan region_name kosong
- // @Test
- // public void Kasus6() {
- //
- // Dto input = new Dto();
- // input.put("tenantId", 10L);
- // input.put("region_code", "BGR");
- // input.put("region_name", "");
- // input.put("active", GeneralConstants.NO);
- //
- // input.put("limit", 10L);
- // input.put("offset", 0L);
- //
- // try {
- // Dto output = getRegionCustomerList.execute(input);
- // log.debug("ini output:" + output);
- // List<Dto> list = output.getList("regionCustomerList");
- //
- // Dto listDto = list.get(0);
- // Assert.assertEquals(1, list.size());
- // Assert.assertEquals("1", listDto.getString("id"));
- // Assert.assertEquals(10L, listDto.getLong("tenantId").longValue());
- // Assert.assertEquals("1", listDto.getString("region_code"));
- // Assert.assertEquals("BGR", listDto.getString("region_name"));
- //
- // } catch (Exception e) {
- // log.error(e.getMessage(), e);
- // }
- //
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment