File indexing completed on 2025-02-02 04:51:25

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "getgrouprolesjobtest.h"
0008 #include "groups/getgrouprolesjob.h"
0009 #include "restapimethod.h"
0010 #include <QTest>
0011 QTEST_GUILESS_MAIN(GetGroupRolesJobTest)
0012 using namespace RocketChatRestApi;
0013 GetGroupRolesJobTest::GetGroupRolesJobTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void GetGroupRolesJobTest::shouldHaveDefaultValue()
0019 {
0020     GetGroupRolesJob job;
0021     QVERIFY(!job.restApiMethod());
0022     QVERIFY(!job.networkAccessManager());
0023     QVERIFY(!job.start());
0024     QVERIFY(job.requireHttpAuthentication());
0025     QVERIFY(!job.hasIdentifier());
0026     QVERIFY(!job.restApiLogger());
0027     QVERIFY(!job.hasQueryParameterSupport());
0028 }
0029 
0030 void GetGroupRolesJobTest::shouldGenerateRequest()
0031 {
0032     GetGroupRolesJob job;
0033     RestApiMethod method;
0034     method.setServerUrl(QStringLiteral("http://www.kde.org"));
0035     job.setRestApiMethod(&method);
0036     const QString roomId = QStringLiteral("avat");
0037     ChannelGroupBaseJob::ChannelGroupInfo info;
0038     info.channelGroupInfoType = ChannelGroupBaseJob::ChannelGroupInfoType::Identifier;
0039     info.identifier = roomId;
0040     job.setChannelGroupInfo(info);
0041     const QNetworkRequest request = job.request();
0042     QCOMPARE(request.url(), QUrl(QStringLiteral("http://www.kde.org/api/v1/groups.roles?roomId=avat")));
0043 }
0044 
0045 #include "moc_getgrouprolesjobtest.cpp"