| 23112 |
ashik.ali |
1 |
package com.spice.profitmandi.service.generic;
|
|
|
2 |
|
|
|
3 |
|
| 23173 |
ashik.ali |
4 |
import java.util.Arrays;
|
|
|
5 |
|
| 23112 |
ashik.ali |
6 |
import org.junit.Ignore;
|
|
|
7 |
import org.junit.Test;
|
|
|
8 |
import org.junit.runner.RunWith;
|
|
|
9 |
import org.slf4j.Logger;
|
|
|
10 |
import org.slf4j.LoggerFactory;
|
|
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
12 |
import org.springframework.test.context.ContextConfiguration;
|
|
|
13 |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
|
14 |
import org.springframework.test.context.web.WebAppConfiguration;
|
|
|
15 |
import org.springframework.transaction.annotation.Transactional;
|
|
|
16 |
|
|
|
17 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 23173 |
ashik.ali |
18 |
import com.spice.profitmandi.common.util.Utils;
|
|
|
19 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 23112 |
ashik.ali |
20 |
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
|
| 23173 |
ashik.ali |
21 |
import com.spice.profitmandi.dao.repository.GenericRepository;
|
|
|
22 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 23112 |
ashik.ali |
23 |
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
|
|
|
24 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
|
|
25 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
|
|
26 |
import com.spice.profitmandi.web.config.AppConfig;
|
|
|
27 |
|
|
|
28 |
@RunWith(SpringJUnit4ClassRunner.class)
|
|
|
29 |
@WebAppConfiguration
|
|
|
30 |
@ContextConfiguration(classes = {AppConfig.class})
|
|
|
31 |
//@ContextConfiguration
|
|
|
32 |
@Transactional
|
|
|
33 |
public class GenericServiceTest {
|
|
|
34 |
|
|
|
35 |
private static final Logger LOGGER = LoggerFactory.getLogger(GenericServiceTest.class);
|
|
|
36 |
|
|
|
37 |
@Autowired
|
|
|
38 |
private SchemeService schemeService;
|
|
|
39 |
|
|
|
40 |
@Autowired
|
|
|
41 |
private InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
|
|
|
42 |
|
|
|
43 |
@Autowired
|
|
|
44 |
private PriceDropService priceDropService;
|
|
|
45 |
|
| 23173 |
ashik.ali |
46 |
@Autowired
|
|
|
47 |
private GenericRepository genericRepository;
|
|
|
48 |
|
|
|
49 |
@Autowired
|
|
|
50 |
private ItemRepository itemRepository;
|
|
|
51 |
|
| 23112 |
ashik.ali |
52 |
//@Test
|
|
|
53 |
@Ignore
|
|
|
54 |
//@Rollback(false)
|
|
|
55 |
public void testprocessSchemeOut() throws ProfitMandiBusinessException{
|
|
|
56 |
//throw new ProfitMandiBusinessException("", "", "");
|
|
|
57 |
try{
|
|
|
58 |
float cashback = schemeService.processSchemeOut(99, 963490);
|
|
|
59 |
LOGGER.info("Cashback : {}", cashback);
|
|
|
60 |
if(cashback == 0){
|
|
|
61 |
throw new ProfitMandiBusinessException("", "", "");
|
|
|
62 |
}
|
|
|
63 |
//LOGGER.info("Cashback : {}", cashback);
|
|
|
64 |
//System.out.println("sdfsdfsdf");
|
|
|
65 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
|
|
66 |
profitMandiBusinessException.printStackTrace();
|
|
|
67 |
throw profitMandiBusinessException;
|
|
|
68 |
}
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
//@Test
|
|
|
72 |
@Ignore
|
|
|
73 |
//@Rollback(false)
|
|
|
74 |
public void testCreateInvoiceNumberGenerationSequence(){
|
|
|
75 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
|
|
76 |
try{
|
|
|
77 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(963490);
|
|
|
78 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
|
|
79 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
|
|
80 |
invoiceNumberGenerationSequence = new InvoiceNumberGenerationSequence();
|
|
|
81 |
invoiceNumberGenerationSequence.setFofoId(963490);
|
|
|
82 |
invoiceNumberGenerationSequence.setPrefix("INVOICE");
|
|
|
83 |
invoiceNumberGenerationSequence.setSequence(1);
|
|
|
84 |
}
|
|
|
85 |
invoiceNumberGenerationSequenceRepository.persist(invoiceNumberGenerationSequence);
|
|
|
86 |
LOGGER.info("invoiceNumberSequence {}", invoiceNumberGenerationSequence.getSequence());
|
|
|
87 |
}
|
|
|
88 |
|
| 23173 |
ashik.ali |
89 |
@Ignore
|
| 23112 |
ashik.ali |
90 |
public void testAddPriceDropAmountToWallet() {
|
|
|
91 |
priceDropService.addPriceDropAmountToWallet();
|
|
|
92 |
}
|
| 23173 |
ashik.ali |
93 |
|
|
|
94 |
@Ignore
|
|
|
95 |
public void testCriteriaBuilderSelectAll(){
|
|
|
96 |
//LOGGER.info("brands {}", genericRepository.selectById(Item.class, 2));
|
|
|
97 |
//LOGGER.info("TEST RESULT {}", itemRepository.selectIdsByIdsAndType(new HashSet<>(Arrays.asList(1,2,3,4,5)), ItemType.SERIALIZED));
|
|
|
98 |
LOGGER.info("Test Result {}", genericRepository.selectById(Item.class, -2));
|
|
|
99 |
}
|
|
|
100 |
|
|
|
101 |
@Ignore
|
|
|
102 |
public void testStateTaxRate() throws ProfitMandiBusinessException{
|
|
|
103 |
LOGGER.info("stateTaxRate {}", Utils.getStateTaxRate(Arrays.asList(1,2), 1));
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
@Ignore
|
|
|
107 |
public void testIgstTaxRate() throws ProfitMandiBusinessException{
|
|
|
108 |
LOGGER.info("igstTaxRate {}", Utils.getIgstTaxRate(Arrays.asList(1,2)));
|
|
|
109 |
}
|
| 23112 |
ashik.ali |
110 |
}
|