package johnny.me.controller;
import com.sparkpost.Client;
import com.sparkpost.model.responses.Response;
import com.sparkpost.exception.SparkPostException;
import org.springframework.stereotype.Service;
/**
* Sparkpost class sends the email using
* the sendmessage methood
*/
@Service 公共类 SparkPostController {
String API_KEY = "API KEY";
Client client = new Client(API_KEY);
private static String from_email = "me@yahoo.com";
private static String subject = "Time equation";
private static String text = "";
public Response sendMessage(String recipient, String message) throws SparkPostException {
return client.sendMessage(from_email,recipient,subject,
text,message);
}
}
这是我的 sparkpost 控制器类。尝试进行单元测试/模拟以发送消息。也称为回归测试请对单元测试非常具体。让我的课程在测试文件夹下制作。这就是我所得到的。