小编Moh*_*een的帖子

使用 Chai 断言比较两个对象

我有两个混合订单数组

const actualResult = [
  {
    start: '30',
    end: '50',
    locations: ['loc1', 'loc2'],
  },
  {
    start: '20',
    end: '40',
    locations: ['loc3', 'loc4'],
  },
];

const expectedResult = [
  {
    start: '20',
    end: '40',
    locations: ['loc4', 'loc3'],
  },
  {
    start: '30',
    end: '50',
    locations: ['loc2', 'loc1'],
  },
];
Run Code Online (Sandbox Code Playgroud)

我编写了下面的代码来使用 chai 断言来比较它们

describe('test1', function () {
  it('expect test', function () {
    expect(actualResult).to.have.length(expectedResult.length);
    for (b of expectedResult) {
      var found = false;
      for (d of actualResult) {
        if (b.start == d.start && b.end …
Run Code Online (Sandbox Code Playgroud)

mocha.js node.js chai

11
推荐指数
1
解决办法
1万
查看次数

使用 IAuthenticationProvider 进行身份验证

我正在尝试获取 Microsoft Office 帐户的会议详细信息。我尝试使用下面的代码

IAuthenticationProvider authProvider = (IAuthenticationProvider) new UsernamePasswordProvider(
    "7d06733e-766f-4c63-846c-5b3825b2d638",
    Arrays.asList("https://graph.microsoft.com/Calender.Read"),
    "professorx@proximex.com",
    "*******",
    NationalCloud.Global,
    "0df3f88a-c04e-40ac-8d41-84dbfb9e24d6",
    "*****");
Run Code Online (Sandbox Code Playgroud)

我不知道为什么会出现以下错误:

类型com.microsoft.graph.httpcore.IAuthenticationProvider无法解析。它是从所需的 .class 文件间接引用的

我的 pom 依赖项如下所示:

IAuthenticationProvider authProvider = (IAuthenticationProvider) new UsernamePasswordProvider(
    "7d06733e-766f-4c63-846c-5b3825b2d638",
    Arrays.asList("https://graph.microsoft.com/Calender.Read"),
    "professorx@proximex.com",
    "*******",
    NationalCloud.Global,
    "0df3f88a-c04e-40ac-8d41-84dbfb9e24d6",
    "*****");
Run Code Online (Sandbox Code Playgroud)

我的代码:

public class MicrosoftGraphHelper
{
    public static void main(String[] args)
    {
        IAuthenticationProvider authProvider = (IAuthenticationProvider) new UsernamePasswordProvider(
            "7d06733e-766f-4c63-846c-5b3825b2d638",
            Arrays.asList("https://graph.microsoft.com/Calender.Read"),
            "professorx@proximex.com",
            "*******",
            NationalCloud.Global,
            "0df3f88a-c04e-40ac-8d41-84dbfb9e24d6",
            "*******");

        GraphServiceClient graphClient = (GraphServiceClient) GraphServiceClient.builder()
            .authenticationProvider(authProvider)
            .buildClient();
    }

Run Code Online (Sandbox Code Playgroud)

java microsoft-graph-api

2
推荐指数
1
解决办法
3136
查看次数

标签 统计

chai ×1

java ×1

microsoft-graph-api ×1

mocha.js ×1

node.js ×1