Subversion Repositories SmartDukaan

Rev

Rev 23203 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.service.generic;


import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
import com.spice.profitmandi.dao.entity.fofo.InvoiceNumberGenerationSequence;
import com.spice.profitmandi.dao.repository.GenericRepository;
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
import com.spice.profitmandi.service.pricing.PriceDropService;
import com.spice.profitmandi.service.scheme.SchemeService;
import com.spice.profitmandi.web.config.AppConfig;
import org.junit.Ignore;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.transaction.annotation.Transactional;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration(classes = {AppConfig.class})
//@ContextConfiguration
@Transactional
public class GenericServiceTest {
        
        private static final Logger LOGGER = LoggerFactory.getLogger(GenericServiceTest.class);
        
        @Autowired
        private SchemeService schemeService;
        
        @Autowired
        private InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
        
        @Autowired
        private PriceDropService priceDropService;
        
        @Autowired
        private GenericRepository genericRepository;
        
        @Autowired
        private ItemRepository itemRepository;
        
        //@Test
        @Ignore
        //@Rollback(false)
        public void testprocessSchemeOut() throws ProfitMandiBusinessException{
                //throw new ProfitMandiBusinessException("", "", "");
                try{
                        float cashback = schemeService.processSchemeOut(99, 963490);
                        LOGGER.info("Cashback : {}", cashback);
                        if(cashback == 0){
                                throw new ProfitMandiBusinessException("", "", "");
                        }
                        //LOGGER.info("Cashback : {}", cashback);
                        //System.out.println("sdfsdfsdf");
                }catch (ProfitMandiBusinessException profitMandiBusinessException) {
                        profitMandiBusinessException.printStackTrace();
                        throw profitMandiBusinessException;
                }
        }
        
        //@Test
        @Ignore
        //@Rollback(false)
        public void testCreateInvoiceNumberGenerationSequence(){
                InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
                try{
                        invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(963490);
                        invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
                }catch(ProfitMandiBusinessException profitMandiBusinessException){
                        invoiceNumberGenerationSequence = new InvoiceNumberGenerationSequence();
                        invoiceNumberGenerationSequence.setFofoId(963490);
                        invoiceNumberGenerationSequence.setPrefix("INVOICE");
                        invoiceNumberGenerationSequence.setSequence(1);
                }
                invoiceNumberGenerationSequenceRepository.persist(invoiceNumberGenerationSequence);
                LOGGER.info("invoiceNumberSequence {}", invoiceNumberGenerationSequence.getSequence());
        }
        
        /*@Ignore
        public void testAddPriceDropAmountToWallet() {
                priceDropService.addPriceDropAmountToWallet();
        }
        
        @Ignore
        public void testCriteriaBuilderSelectAll(){
                //LOGGER.info("brands {}", genericRepository.selectById(Item.class, 2));
                //LOGGER.info("TEST RESULT {}", itemRepository.selectIdsByIdsAndType(new HashSet<>(Arrays.asList(1,2,3,4,5)), ItemType.SERIALIZED));
                LOGGER.info("Test Result {}", genericRepository.selectById(Item.class, -2));
        }
        
        @Ignore
        public void testStateTaxRate() throws ProfitMandiBusinessException{
                LOGGER.info("stateTaxRate {}", Utils.getStateTaxRate(Arrays.asList(1,2), 1));
        }
        
        @Ignore
        public void testIgstTaxRate() throws ProfitMandiBusinessException{
                LOGGER.info("igstTaxRate {}", Utils.getIgstTaxRate(Arrays.asList(1,2)));
        }*/

}