gpt4 book ai didi

java - 尝试找到 Maven 的 InvoiceStorage 依赖项

转载 作者:行者123 更新时间:2023-12-01 23:54:56 26 4
gpt4 key购买 nike

我正在遵循一个具有外部类 InvoiceStorage 的教程,我认为,我对此非常菜鸟,但 java 无法解析该 InvoiceStorage 符号,所以我认为我需要一个教程中未显示的依赖项

教程链接: https://semaphoreci.com/community/tutorials/stubbing-and-mocking-with-mockito-2-and-junit


package com.mokitoTutorial.app;

import com.clusterra.email.sender.EmailSender;


public class LateInvoiceNotifier {
private final EmailSender emailSender;
private final InvoiceStorage invoiceStorage;

public LateInvoiceNotifier(final EmailSender emailSender, final InvoiceStorage invoiceStorage){
this.emailSender = emailSender;
this.invoiceStorage = invoiceStorage;
}

public void notifyIfLate(Customer customer)
{
if(invoiceStorage.hasOutstandingInvoice(customer)){
emailSender.sendEmail(customer);
}
}
}

最佳答案

在这篇文章中,作者只是提供了一个如何使用mockito的示例。您可以从上面的文章中看到以下内容。

In a real system, the InvoiceStorage class is actually a web service that connects with an external legacy CRM system which is slow. A unit test could never make use of such as web service.

作者指的是一个名为InvoiceStorage的类,它是例如。没有依赖性。您可以按照这篇文章创建自己的类来测试。

关于java - 尝试找到 Maven 的 InvoiceStorage 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58205987/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com