所以我正在测试一些网关,我有这个更新方法:
@Override
public Mono<Boolean> update(CustomerInfo info) {
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setCustomerId(info.getCustomerId());
customerEntity.setName(info.getName());
customerEntity.setLastName(info.getLastName());
customerEntity.setBirthDate(info.getBirthDate());
Expression itemExistsExpression = Expression.builder()
.expression("attribute_exists(customerId)")
.build();
UpdateItemEnhancedRequest<PhysicalcardCustomerInfoEntity> updateItemEnhancedRequest = UpdateItemEnhancedRequest
.builder(CustomerEntity.class)
.item(customerEntity)
.conditionExpression(itemExistsExpression)
.ignoreNulls(true)
.build();
this.customerAdapter.getCustomerTable().updateItem(updateItemEnhancedRequest)
.thenRun(() -> log.info("Updated in DynamoDB!"));
return Mono.just(true);
}
我在尝试测试此方法时遇到问题,我认为问题出在
this.customerAdapter.getCustomerTable().updateItem(updateItemEnhancedRequest).thenRun(() -> log.info("Updated in DynamoDB!"));
客户表是
private final DynamoDbAsyncTable<V> customerTable;
有人可以帮忙吗?
我试过
@Test
void updateCustomerInfo() {
Mockito.when(customerAdapter.getCustomerTable().updateItem(any(UpdateItemEnhancedRequest.class)))
.thenReturn(Mono.empty().toFuture());
Mono<Boolean> infoMono = customerGateway.update(dynamoData.get(0));
StepVerifier.create(infoMono).expectComplete().verify();
}
但没有成功。