Index: src/main/java/com/napa/pulse/dao/impl/SessionDAOImpl.java =================================================================== diff -u -rba270d62a3472b9538d0e718b44ba445262842c3 -r7da583b61621043174172bc3e6becd96dc446b3b --- src/main/java/com/napa/pulse/dao/impl/SessionDAOImpl.java (.../SessionDAOImpl.java) (revision ba270d62a3472b9538d0e718b44ba445262842c3) +++ src/main/java/com/napa/pulse/dao/impl/SessionDAOImpl.java (.../SessionDAOImpl.java) (revision 7da583b61621043174172bc3e6becd96dc446b3b) @@ -542,16 +542,16 @@ includeHubSpokeOrderOption , includeHubSpokeReturnOption , null , applicationPartsOnly ); } - private BigDecimal createNewSession ( User user , Boolean perCarOrder , Boolean includeFleets , Boolean includeSystems , - Boolean includeSpecials , Boolean includeObsoletes , Boolean includeOverstocks , Boolean includeSupersede , Boolean includeKeylinesOrders , - Boolean includeKeylinesReturns , Boolean includeLessThanStdPkg ,Double includeWeekSupplyOption,String weekSupplyOptionName, Boolean useInvestmentCollections , - Boolean provideStoreDepth , Boolean includeSoldNotStocked , Boolean includeNewNumbers , Boolean orderAllSkus , Boolean returnAllSKUs , - Integer dollarLimit , String comment , Integer siteGroupId , String siteGroupName , Integer[] sitesArray , - ProductGroupOrderReturn[] productGroupsArray , ProductGroupOrderReturn[] groupCodeArray , Integer[] fleetGroupsIds , - CustomProductGroup customProductGroup , CustomGroupCodeProductGroup customGroupCodeProductGroupObj , Boolean isGroupCode , String savedGroup , String userAccessSites , Integer[] skuArray , ProductLinesData[] productLineIdArray , ProductLinesData[] allProductLines ,ProductLinesData[] siteProductLines, - Integer includeOrders , Integer includeReturns , Date expirationDate , String includeDaysCount , Integer perCarMinMaxValue , - String salesHistoryValue , String displayQty , String sessionType , String includeHubSpokeOrderOption , - String includeHubSpokeReturnOption , Long createdFromSessionId , Boolean applicationPartsOnly ) throws Exception { + BigDecimal createNewSession(User user, Boolean perCarOrder, Boolean includeFleets, Boolean includeSystems, + Boolean includeSpecials, Boolean includeObsoletes, Boolean includeOverstocks, Boolean includeSupersede, Boolean includeKeylinesOrders, + Boolean includeKeylinesReturns, Boolean includeLessThanStdPkg, Double includeWeekSupplyOption, String weekSupplyOptionName, Boolean useInvestmentCollections, + Boolean provideStoreDepth, Boolean includeSoldNotStocked, Boolean includeNewNumbers, Boolean orderAllSkus, Boolean returnAllSKUs, + Integer dollarLimit, String comment, Integer siteGroupId, String siteGroupName, Integer[] sitesArray, + ProductGroupOrderReturn[] productGroupsArray, ProductGroupOrderReturn[] groupCodeArray, Integer[] fleetGroupsIds, + CustomProductGroup customProductGroup, CustomGroupCodeProductGroup customGroupCodeProductGroupObj, Boolean isGroupCode, String savedGroup, String userAccessSites, Integer[] skuArray, ProductLinesData[] productLineIdArray, ProductLinesData[] allProductLines, ProductLinesData[] siteProductLines, + Integer includeOrders, Integer includeReturns, Date expirationDate, String includeDaysCount, Integer perCarMinMaxValue, + String salesHistoryValue, String displayQty, String sessionType, String includeHubSpokeOrderOption, + String includeHubSpokeReturnOption, Long createdFromSessionId, Boolean applicationPartsOnly) throws Exception { boolean shouldBeDeferred = false; if ( user.getAccessItemIds ( ) != null && user.getAccessItemIds ( ).contains ( AccessItem.DELAY_SESSION_CREATION.getNumVal ( ) ) ) { @@ -660,8 +660,7 @@ LOGGER.info ( "Create new session| the row is created " + row ); - if ( row > 0 ) { - + if ( row > 0 ) { final BigDecimal sessionId = (BigDecimal) keyHolder.getKey ( ); LOGGER.info ( "Create new session|keyholder for sessionId " + sessionId + "keyHolder " + keyHolder ); Index: src/test/java/com/napa/pulse/dao/impl/SessionDAOImplUnitTest.java =================================================================== diff -u -r632edbfd8fd338838bacd48d2e14eac01602166e -r7da583b61621043174172bc3e6becd96dc446b3b --- src/test/java/com/napa/pulse/dao/impl/SessionDAOImplUnitTest.java (.../SessionDAOImplUnitTest.java) (revision 632edbfd8fd338838bacd48d2e14eac01602166e) +++ src/test/java/com/napa/pulse/dao/impl/SessionDAOImplUnitTest.java (.../SessionDAOImplUnitTest.java) (revision 7da583b61621043174172bc3e6becd96dc446b3b) @@ -1,21 +1,41 @@ package com.napa.pulse.dao.impl; +import com.napa.pulse.dao.interfaces.SiteGroupDAO; +import com.napa.pulse.dto.ProductLinesData; +import com.napa.pulse.entity.pulseui.CustomGroupCodeProductGroup; +import com.napa.pulse.entity.pulseui.CustomProductGroup; +import com.napa.pulse.entity.pulseui.ProductGroupOrderReturn; +import com.napa.pulse.entity.security.User; +import com.napa.pulse.enums.AccessItem; +import com.napa.pulse.service.interfaces.SessionService; +import org.junit.Before; import org.junit.Test; import org.junit.jupiter.api.BeforeEach; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.*; import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementCreator; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.simple.SimpleJdbcCall; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.test.util.ReflectionTestUtils; -import java.util.HashMap; -import java.util.Map; +import javax.sql.DataSource; +import java.math.BigDecimal; +import java.sql.*; +import java.util.*; +import java.util.Date; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; /** * @author Rahul Chaudhary @@ -28,16 +48,114 @@ SessionDAOImpl sessionDAOImplMock; @Mock + User user; + + @Mock private JdbcTemplate jdbcTemplate; @Mock - private SimpleJdbcCall simpleJdbcCall; + private Connection connection; + @Mock + private NamedParameterJdbcTemplate namedParameterJdbcTemplate; + @Mock + private SiteGroupDAO siteGroupDAO; - @BeforeEach - public void setup() { + @Mock + private DataSource dataSource; + + @Mock + private PreparedStatement ps; + + @Mock + private ResultSet rs; + + + private static final int DEFER_SITE_LIMIT = 10; // Example limit + @Before + public void setup() throws Exception{ + assertNotNull(dataSource); MockitoAnnotations.initMocks(this); + jdbcTemplate = mock(JdbcTemplate.class); + when(connection.prepareStatement(any(String.class))).thenReturn(ps); + when(dataSource.getConnection()).thenReturn(connection); + User user1 = buildUser(); + Integer num = 1; + Integer[] sitesArray = {1309,1346}; + + Boolean perCarOrder = true; + Boolean includeFleets = false; + Boolean includeSystems = true; + Boolean includeSpecials = true; + Boolean includeObsoletes = true; + Boolean includeOverstocks = true; + Boolean includeSupersede = true; + Boolean includeKeylinesOrders = true; + Boolean includeKeylinesReturns= true; + Boolean includeLessThanStdPkg = true; + Double includeWeekSupplyOption = null; + String weekSupplyOptionName = null; + Boolean useInvestmentCollections = true; + Boolean provideStoreDepth = true; Boolean includeSoldNotStocked = false; + Boolean includeNewNumbers= false ; Boolean orderAllSkus= false ; Boolean returnAllSKUs= false ; + Integer dollarLimit = 0; String comment=null; Integer siteGroupId = 0; String siteGroupName = null; + ProductGroupOrderReturn productGroupOrderReturn = new ProductGroupOrderReturn(); + productGroupOrderReturn.setProductGroupId(8839); + productGroupOrderReturn.setOrders(true); + productGroupOrderReturn.setProductGroupName("*Pulse Round 1 2023"); + productGroupOrderReturn.setReturns(true); + ProductGroupOrderReturn[] productGroupsArray = {productGroupOrderReturn}; + // productGroupsArray.set + ProductGroupOrderReturn[] groupCodeArray = null; + Integer[] fleetGroupsIds = null; + CustomProductGroup customProductGroup = null; + CustomGroupCodeProductGroup customGroupCodeProductGroupObj = null; + Boolean isGroupCode = false; + String savedGroup = null; + String userAccessSites = null; + Integer[] skuArray = null; + ProductLinesData[] productLineIdArray = null; + ProductLinesData[] allProductLines = null; + ProductLinesData[] siteProductLines = null; + Integer includeOrders = 0; + Integer includeReturns = 0; + Date expirationDate = null; + String includeDaysCount = "365"; + Integer perCarMinMaxValue = 1; + String salesHistoryValue = null; + BigDecimal ans = new BigDecimal("589734"); + int row = 1; + String displayQty= null; String sessionType = "MM"; String includeHubSpokeOrderOption = "B"; + String includeHubSpokeReturnOption = "B"; Long createdFromSessionId = null; Boolean applicationPartsOnly = true; + sessionDAOImplMock.createNewSession(user1 , perCarOrder , includeFleets , includeSystems , includeSpecials , includeObsoletes , + includeOverstocks , includeSupersede , includeKeylinesOrders , includeKeylinesReturns , includeLessThanStdPkg ,includeWeekSupplyOption,weekSupplyOptionName, + useInvestmentCollections , provideStoreDepth , includeSoldNotStocked , includeNewNumbers , orderAllSkus , returnAllSKUs , + dollarLimit , comment , siteGroupId , "Custom Group" , sitesArray , + productGroupsArray , groupCodeArray , fleetGroupsIds , customProductGroup , customGroupCodeProductGroupObj , isGroupCode , savedGroup , userAccessSites , skuArray , productLineIdArray , allProductLines , siteProductLines, + includeOrders , includeReturns , expirationDate , includeDaysCount , perCarMinMaxValue , salesHistoryValue , displayQty , sessionType , + includeHubSpokeOrderOption , includeHubSpokeReturnOption , null , applicationPartsOnly ); + when(rs.getBoolean(10)).thenReturn(includeLessThanStdPkg); + when(rs.getString(11)).thenReturn(sessionType); + when(rs.getInt(12)).thenReturn(user1.getRoleId()); + when(rs.getString(24)).thenReturn(includeDaysCount); + when(rs.getString(26)).thenReturn(includeHubSpokeOrderOption); + when(rs.getBoolean(16)).thenReturn(useInvestmentCollections); + when(rs.getBoolean(18)).thenReturn(provideStoreDepth); + when(rs.getInt(1)).thenReturn(2); + + + when(ps.executeQuery()).thenReturn(rs); + + + } + /* @Before + public void setUpp(){ + MockitoAnnotations.initMocks(this); + namedParameterJdbcTemplate = mock(namedParameterJdbcTemplate.class); + }*/ + + @Test public void testRecalculateSessionTotals() { sessionDAOImplMock = mock(SessionDAOImpl.class); @@ -64,4 +182,181 @@ SimpleJdbcCall simpleJdbcCall = new SimpleJdbcCall(jdbcTemplate).withProcedureName("RECALC_SESSION_TOTALS"); when(simpleJdbcCall.execute(in)).thenThrow(Exception.class); } + + @Test + public void getMinMaxSessionProductsTest() { + //sessionDAOImplMock = mock(SessionDAOImpl.class); + Integer[] sites = {1309,1346}; + //String sql = "" + List> obj = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("ac",1309); + obj.add(map); + Map>> ans = new HashMap<>(); + ans.put("ad",obj); + ReflectionTestUtils.setField(sessionDAOImplMock, "jdbcTemplate", jdbcTemplate); + when(jdbcTemplate.queryForList(anyString())).thenReturn(obj); + sessionDAOImplMock.getMinMaxSessionProducts(sites); + assertThat(ans).isNotNull(); + + } + @Test + public void testCreateNewSession() throws Exception { + // Set up your test data and mock responses + + /*User user1 = buildUser(); + Integer num = 1; + Integer[] sitesArray = {1309,1346}; + + Boolean perCarOrder = true; + Boolean includeFleets = false; + Boolean includeSystems = true; + Boolean includeSpecials = true; + Boolean includeObsoletes = true; + Boolean includeOverstocks = true; + Boolean includeSupersede = true; + Boolean includeKeylinesOrders = true; + Boolean includeKeylinesReturns= true; + Boolean includeLessThanStdPkg = true; + Double includeWeekSupplyOption = null; + String weekSupplyOptionName = null; + Boolean useInvestmentCollections = true; + Boolean provideStoreDepth = true; Boolean includeSoldNotStocked = false; + Boolean includeNewNumbers= false ; Boolean orderAllSkus= false ; Boolean returnAllSKUs= false ; + Integer dollarLimit = 0; String comment=null; Integer siteGroupId = 0; String siteGroupName = null; + ProductGroupOrderReturn productGroupOrderReturn = new ProductGroupOrderReturn(); + productGroupOrderReturn.setProductGroupId(8839); + productGroupOrderReturn.setOrders(true); + productGroupOrderReturn.setProductGroupName("*Pulse Round 1 2023"); + productGroupOrderReturn.setReturns(true); + ProductGroupOrderReturn[] productGroupsArray = {productGroupOrderReturn}; + // productGroupsArray.set + ProductGroupOrderReturn[] groupCodeArray = null; + Integer[] fleetGroupsIds = null; + CustomProductGroup customProductGroup = null; + CustomGroupCodeProductGroup customGroupCodeProductGroupObj = null; + Boolean isGroupCode = false; + String savedGroup = null; + String userAccessSites = null; + Integer[] skuArray = null; + ProductLinesData[] productLineIdArray = null; + ProductLinesData[] allProductLines = null; + ProductLinesData[] siteProductLines = null; + Integer includeOrders = 0; + Integer includeReturns = 0; + Date expirationDate = null; + String includeDaysCount = "365"; + Integer perCarMinMaxValue = 1; + String salesHistoryValue = null; + BigDecimal ans = new BigDecimal("589734"); + int row = 1; + String displayQty= null; String sessionType = "MM"; String includeHubSpokeOrderOption = "B"; + String includeHubSpokeReturnOption = "B"; Long createdFromSessionId = null; Boolean applicationPartsOnly = true;*/ + when(user.getAccessItemIds()).thenReturn(Arrays.asList(AccessItem.DELAY_SESSION_CREATION.getNumVal())); + when(siteGroupDAO.getSiteCount(anyInt(), any(User.class), anyString(), anyString())).thenReturn(DEFER_SITE_LIMIT + 1); + // Call the method to test + // when(row >0).thenT + //sessionDAOImplMock = new SessionDAOImpl(); + //ReflectionTestUtils.setField(sessionDAOImplMock, "jdbcTemplate", jdbcTemplate); + //when(jdbcTemplate.update((PreparedStatementCreator)sessionDAOImplMock.createNewSession(), any(KeyHolder.class))).thenReturn(row); + // when(ps.executeQuery()).thenReturn(); + /* sessionDAOImplMock.createNewSession(user1 , perCarOrder , includeFleets , includeSystems , includeSpecials , includeObsoletes , + includeOverstocks , includeSupersede , includeKeylinesOrders , includeKeylinesReturns , includeLessThanStdPkg ,includeWeekSupplyOption,weekSupplyOptionName, + useInvestmentCollections , provideStoreDepth , includeSoldNotStocked , includeNewNumbers , orderAllSkus , returnAllSKUs , + dollarLimit , comment , siteGroupId , "Custom Group" , sitesArray , + productGroupsArray , groupCodeArray , fleetGroupsIds , customProductGroup , customGroupCodeProductGroupObj , isGroupCode , savedGroup , userAccessSites , skuArray , productLineIdArray , allProductLines , siteProductLines, + includeOrders , includeReturns , expirationDate , includeDaysCount , perCarMinMaxValue , salesHistoryValue , displayQty , sessionType , + includeHubSpokeOrderOption , includeHubSpokeReturnOption , null , applicationPartsOnly );*/ + //when(row > 0).thenReturn(true); + // Verify the results + assertThat(rs).isNotNull(); + // Add more assertions here based on expected results + // Verify interactions with the mock objects + // when(jdbcTemplate.update(any(PreparedStatementCreator.class), any(KeyHolder.class))).thenReturn(row); + // Add more verifications here + } + // Additional test cases to cover different branches and conditions + // ... + + + private User buildUser() { + User testUser = new User(); + testUser.setUserId(15600); + testUser.setFirstName("Test"); + testUser.setLastName("user"); + testUser.setLogin("login"); + testUser.setRoleId(1); + testUser.setAccessItemIds(Arrays.asList(1, 2, 3)); + testUser.setLanguage("EN"); + testUser.setBusinessUnit(1); + testUser.setDeactivated("N"); + testUser.setSiteTypes(Arrays.asList("dc", "sku", "ab")); + + return testUser; + } + /* @Test + public void testCreateSessionException() throws Exception { + //sessionDAOImplMock = mock(SessionDAOImpl.class); + Integer num = 1; + //Integer num1 = 589734; + User user = buildUser(); + // user.setFirstName("Gayathri"); + //user.setLastName("Rayala"); + Integer[] sitesArray = {1309,1346}; + + Boolean perCarOrder = true; + Boolean includeFleets = false; + Boolean includeSystems = true; + Boolean includeSpecials = true; + Boolean includeObsoletes = true; + Boolean includeOverstocks = true; + Boolean includeSupersede = true; + Boolean includeKeylinesOrders = true; + Boolean includeKeylinesReturns= true; + Boolean includeLessThanStdPkg = false; + Double includeWeekSupplyOption = 19.0; + String weekSupplyOptionName = null; + Boolean useInvestmentCollections = null; + Boolean provideStoreDepth = false; Boolean includeSoldNotStocked = false; + Boolean includeNewNumbers= false ; Boolean orderAllSkus= false ; Boolean returnAllSKUs= false ; + Integer dollarLimit = 0; String comment=null; Integer siteGroupId = 0; String siteGroupName = null; + ProductGroupOrderReturn[] productGroupsArray = null; + ProductGroupOrderReturn[] groupCodeArray = null; + Integer[] fleetGroupsIds = null; + CustomProductGroup customProductGroup = null; + CustomGroupCodeProductGroup customGroupCodeProductGroupObj = null; + Boolean isGroupCode = false; + String savedGroup = null; + String userAccessSites = null; + Integer[] skuArray = null; + ProductLinesData[] productLineIdArray = null; + ProductLinesData[] allProductLines = null; + ProductLinesData[] siteProductLines = null; + Integer includeOrders = 0; + Integer includeReturns = 0; + Date expirationDate = null; + String includeDaysCount = null; + Integer perCarMinMaxValue = 1; + String salesHistoryValue = null; + BigDecimal ans = new BigDecimal("589734"); + String displayQty= null; String sessionType = "MM"; String includeHubSpokeOrderOption = null; + String includeHubSpokeReturnOption = null; Long createdFromSessionId = null; Boolean applicationPartsOnly = true; + // when(jdbcTemplate.queryForObject("select SETTING_ID from MIN_MAX_SESSION_SETTING where SETTING_CODE = 'MINGTPERCAR' AND SETTING_TYPE = 'MIN' ", Integer.class)).thenReturn(num); + when(sessionDAOImplMock.createNewSession(user , perCarOrder , includeFleets , includeSystems , includeSpecials , includeObsoletes , + includeOverstocks , includeSupersede , includeKeylinesOrders , includeKeylinesReturns , includeLessThanStdPkg ,includeWeekSupplyOption,weekSupplyOptionName, + useInvestmentCollections , provideStoreDepth , includeSoldNotStocked , includeNewNumbers , orderAllSkus , returnAllSKUs , + dollarLimit , comment , siteGroupId , "Custom Group" , sitesArray , + productGroupsArray , groupCodeArray , fleetGroupsIds , customProductGroup , customGroupCodeProductGroupObj , isGroupCode , savedGroup , userAccessSites , skuArray , productLineIdArray , allProductLines , siteProductLines, + includeOrders , includeReturns , expirationDate , includeDaysCount , perCarMinMaxValue , salesHistoryValue , displayQty , sessionType , + includeHubSpokeOrderOption , includeHubSpokeReturnOption , null , applicationPartsOnly)).thenReturn(ans); + sessionDAOImplMock.createNewSession(user , perCarOrder , includeFleets , includeSystems , includeSpecials , includeObsoletes , + includeOverstocks , includeSupersede , includeKeylinesOrders , includeKeylinesReturns , includeLessThanStdPkg ,includeWeekSupplyOption,weekSupplyOptionName, + useInvestmentCollections , provideStoreDepth , includeSoldNotStocked , includeNewNumbers , orderAllSkus , returnAllSKUs , + dollarLimit , comment , siteGroupId , "Custom Group" , sitesArray , + productGroupsArray , groupCodeArray , fleetGroupsIds , customProductGroup , customGroupCodeProductGroupObj , isGroupCode , savedGroup , userAccessSites , skuArray , productLineIdArray , allProductLines , siteProductLines, + includeOrders , includeReturns , expirationDate , includeDaysCount , perCarMinMaxValue , salesHistoryValue , displayQty , sessionType , + includeHubSpokeOrderOption , includeHubSpokeReturnOption , null , applicationPartsOnly ); + assertThat(ans).isNotNull(); + }*/ + } Index: src/test/java/com/napa/pulse/dao/impl/SiteGroupDAOImpUnitTest.java =================================================================== diff -u --- src/test/java/com/napa/pulse/dao/impl/SiteGroupDAOImpUnitTest.java (revision 0) +++ src/test/java/com/napa/pulse/dao/impl/SiteGroupDAOImpUnitTest.java (revision 7da583b61621043174172bc3e6becd96dc446b3b) @@ -0,0 +1,363 @@ +package com.napa.pulse.dao.impl; + + +import com.napa.pulse.entity.pulseui.MinMaxClacLn; +import com.napa.pulse.repository.LeadTimeRepository; +import com.napa.pulse.repository.SiteRepository; +import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.jdbc.InvalidResultSetAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.simple.SimpleJdbcCall; +import org.springframework.jdbc.support.rowset.SqlRowSet; +import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; +import org.springframework.test.util.ReflectionTestUtils; + +import java.math.BigDecimal; +import java.sql.Date; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.MockitoAnnotations.initMocks; + +@SpringBootTest +@RunWith(MockitoJUnitRunner.class) +public class SiteGroupDAOImpUnitTest { + @InjectMocks + SiteGroupDAOImpl siteGroupDAO; + + + + @Mock + private JdbcTemplate jdbcTemplate; + + + + @BeforeEach + public void setup() { + initMocks(this); + } + + + + @Test + public void getLeadTimeSiteStatusTest() { + Map rs = new HashMap<>(); + Map rs1 = new HashMap<>(); + rs1.put("1", "N"); + siteGroupDAO = new SiteGroupDAOImpl(); + Integer site_Id = 1247; + Integer[] site_Ids = {1247}; + + + ReflectionTestUtils.setField(siteGroupDAO, "jdbcTemplate", jdbcTemplate); + SqlRowSet sqlRowSet = new SqlRowSet() { + @Override + public SqlRowSetMetaData getMetaData() { + return null; + } + + @Override + public int findColumn(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public boolean getBoolean(int columnIndex) throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean getBoolean(String columnLabel) throws InvalidResultSetAccessException { + return false; + } + + @Override + public byte getByte(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public byte getByte(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public Date getDate(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Date getDate(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public double getDouble(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public double getDouble(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public float getFloat(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public float getFloat(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public int getInt(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public int getInt(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public long getLong(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public long getLong(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public String getNString(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public String getNString(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Object getObject(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Object getObject(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Object getObject(int columnIndex, Map> map) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Object getObject(String columnLabel, Map> map) throws InvalidResultSetAccessException { + return null; + } + + @Override + public T getObject(int columnIndex, Class type) throws InvalidResultSetAccessException { + return null; + } + + @Override + public T getObject(String columnLabel, Class type) throws InvalidResultSetAccessException { + return null; + } + + @Override + public short getShort(int columnIndex) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public short getShort(String columnLabel) throws InvalidResultSetAccessException { + return 0; + } + + @Override + public String getString(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public String getString(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Time getTime(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Time getTime(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException { + return null; + } + + @Override + public boolean absolute(int row) throws InvalidResultSetAccessException { + return false; + } + + @Override + public void afterLast() throws InvalidResultSetAccessException { + + } + + @Override + public void beforeFirst() throws InvalidResultSetAccessException { + + } + + @Override + public boolean first() throws InvalidResultSetAccessException { + return false; + } + + @Override + public int getRow() throws InvalidResultSetAccessException { + return 0; + } + + @Override + public boolean isAfterLast() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean isBeforeFirst() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean isFirst() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean isLast() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean last() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean next() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean previous() throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean relative(int rows) throws InvalidResultSetAccessException { + return false; + } + + @Override + public boolean wasNull() throws InvalidResultSetAccessException { + return false; + } + }; + //sqlRowSet.add() + when(jdbcTemplate.queryForRowSet("select distinct is_selected from Min_Max_Site_Preferences where SITE_ID =? ", site_Id)).thenReturn(sqlRowSet); + // siteGroupDAO.getLeadTimeSiteStatus(site_Ids; + List isselcted = new ArrayList<>(); + isselcted.add(1); + if (isselcted.contains(1)) { + + + rs = siteGroupDAO.getLeadTimeSiteStatus(site_Ids); + } + assertThat(rs).isNotNull(); + + } + /* public void saveLeadTimeTest(){ + Integer macId = 1; + int site_id = 1470; + String fieldAbbr = "ac"; + //MinMaxClacLn min = getMinMaxClacLn(); + when( siteRepo.findSiteId(macId)).thenReturn(site_id); + //MinMaxClacLn obj = leadTimeRepo.getMinMaxClacLnByFieldLine(fdLnGrCd.getFldLineAbbr()); + // when(leadTimeRepo.getMinMaxClacLnByFieldLine(fieldAbbr)).thenReturn(min); + + }*/ + + +} \ No newline at end of file Index: src/test/java/com/napa/pulse/service/impl/SessionServiceImplTest.java =================================================================== diff -u --- src/test/java/com/napa/pulse/service/impl/SessionServiceImplTest.java (revision 0) +++ src/test/java/com/napa/pulse/service/impl/SessionServiceImplTest.java (revision 7da583b61621043174172bc3e6becd96dc446b3b) @@ -0,0 +1,16 @@ +package com.napa.pulse.service.impl; + +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.runners.MockitoJUnitRunner; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +@RunWith(MockitoJUnitRunner.class) +public class SessionServiceImplTest { + @InjectMocks + SessionServiceImpl sessionServiceImpl; + + + +}