mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Mocked TestItemGetter
This commit is contained in:
parent
89ecda9f6b
commit
4048ca1ea6
@ -1,4 +1,6 @@
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.Mockito.*;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@ -12,15 +14,15 @@ public class TestItemGetter {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testItemGetterValid() {
|
public void testItemGetterValid() {
|
||||||
conductItemGetterTest(false);
|
conductItemGetterTestMock(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testItemGetterError() {
|
public void testItemGetterError() {
|
||||||
conductItemGetterTest(true);
|
conductItemGetterTestMock(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void conductItemGetterTest(boolean shouldThrow) {
|
public void conductItemGetterTestMock(boolean shouldThrow) {
|
||||||
ArrayList<Object> rsReturns = new ArrayList<>();
|
ArrayList<Object> rsReturns = new ArrayList<>();
|
||||||
rsReturns.add(1);//ProductID
|
rsReturns.add(1);//ProductID
|
||||||
rsReturns.add(2);//chainID
|
rsReturns.add(2);//chainID
|
||||||
@ -37,7 +39,7 @@ public class TestItemGetter {
|
|||||||
} catch (SQLException throwables) {
|
} catch (SQLException throwables) {
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
ItemGetter getter = new ItemGetter(injector, "id");
|
ItemGetter getter = Mockito.spy(new ItemGetter(injector, "id"));
|
||||||
Map<String, Object> ignore = new HashMap<>();
|
Map<String, Object> ignore = new HashMap<>();
|
||||||
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
HashMap<String, String> queryParams = TestInputUtils.addQueryParams(ignore);
|
||||||
queryParams.put("id", "1");
|
queryParams.put("id", "1");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user