Skip to content

Commit

Permalink
add mocks for the select statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Rwolfe-Nava committed Jun 11, 2024
1 parent aa91226 commit f869186
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand All @@ -28,11 +29,14 @@

@ExtendWith({S3MockAPIExtension.class})
class OptOutProcessorTest {
private static final ResultSet resultSet = mock(ResultSet.class);
private static final PreparedStatement preparedStatement = mock(PreparedStatement.class);
private static final Connection dbConnection = mock(Connection.class);
private static final MockedStatic<OptOutParameterStore> parameterStore = mockStatic(OptOutParameterStore.class);
private static final String DATE = new SimpleDateFormat(EFFECTIVE_DATE_PATTERN).format(new Date());
private static final String MBI = "DUMMY000001";
private static final String TRAILER_COUNT = "0000000001";
private static final int TEST_TOTAL_RESULT_COUNT = 7;
private static String validLine(char isOptOut) {
return MBI + isOptOut;
}
Expand All @@ -44,7 +48,10 @@ static void beforeAll() throws SQLException {

mockStatic(DriverManager.class)
.when(() -> DriverManager.getConnection(anyString(), anyString(), anyString())).thenReturn(dbConnection);
when(dbConnection.prepareStatement(anyString())).thenReturn(mock(PreparedStatement.class));
when(dbConnection.prepareStatement(anyString())).thenReturn(preparedStatement);
when(preparedStatement.executeQuery(anyString())).thenReturn(resultSet);
when(resultSet.next()).thenReturn(true).thenReturn(false);
when(resultSet.getInt(any())).thenReturn(TEST_TOTAL_RESULT_COUNT);
}

@BeforeEach
Expand Down

0 comments on commit f869186

Please sign in to comment.