I have following two methods which i want to test
public class Orders {
private final LambdaLogger logger;
private final DynamoDBMapper dynamoDBMapper;
public Orders(LambdaLogger logger, AmazonDynamoDB amazonDynamoDB){
this.logger = logger;
this.dynamoDBMapper = new DynamoDBMapper(amazonDynamoDB);
}
public List<Orders> getOrders(){
logger.log("getting all orders");
DynamoDBScanExpression scanExpression = new DynamoDBScanExpression()
.withProjectionExpression("OrderId");
logger.log("Expression created");
PaginatedScanList<Orders> scan = dynamoDBMapper.scan(Orders.class, scanExpression);
return scan.stream()
.collect(Collectors.toList());
}
}
Now, I want to do testing using Mockito for this class. There are couple of things that I am confuse (or unable to get working).
First, DynamoDBMapper
is being created using amazonDynamoDBClient
. So if in my class i Mock
AmazonDynamoDB
, how the dynamoDBMapper
would get created?
How would I test that my function is actually setting projection right?
How would i test on paginatedScanList?
Aucun commentaire:
Enregistrer un commentaire