|
| 1 | +/* |
| 2 | +Copyright 2020 Twitter, Inc. |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +
|
| 5 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +you may not use this file except in compliance with the License. |
| 7 | +You may obtain a copy of the License at |
| 8 | +
|
| 9 | +http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +
|
| 11 | +Unless required by applicable law or agreed to in writing, software |
| 12 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +See the License for the specific language governing permissions and |
| 15 | +limitations under the License. |
| 16 | +
|
| 17 | +NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). |
| 18 | +https://openapi-generator.tech |
| 19 | +Do not edit the class manually. |
| 20 | +*/ |
| 21 | + |
| 22 | + |
| 23 | +package com.twitter.clientlib.integration; |
| 24 | + |
| 25 | +import org.junit.jupiter.api.BeforeAll; |
| 26 | +import org.junit.jupiter.api.Test; |
| 27 | +import org.junit.jupiter.api.TestInstance; |
| 28 | + |
| 29 | +import com.twitter.clientlib.ApiException; |
| 30 | +import com.twitter.clientlib.model.*; |
| 31 | + |
| 32 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 33 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 34 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 35 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +@TestInstance(TestInstance.Lifecycle.PER_CLASS) |
| 40 | +public class ApiComplianceTester extends ApiTester { |
| 41 | + |
| 42 | + String complianceJobByID = "1537616980307456001"; //1382081613278814209 |
| 43 | + String complianceJobByIDNotFound = "998837616980307456099"; //1382081613278814209 |
| 44 | + |
| 45 | + @BeforeAll |
| 46 | + public void init() { |
| 47 | + initApiInstanceBearer(); |
| 48 | + } |
| 49 | + |
| 50 | + public CreateComplianceJobResponse createCompliance() throws ApiException { |
| 51 | + CreateComplianceJobRequest req = new CreateComplianceJobRequest(); |
| 52 | + req.setType(CreateComplianceJobRequest.TypeEnum.TWEETS); |
| 53 | + return apiInstance.compliance().createBatchComplianceJob(req) |
| 54 | + .execute(); |
| 55 | + } |
| 56 | + |
| 57 | + @Test |
| 58 | + public void getBatchComplianceJobJobTest() throws ApiException { |
| 59 | + String id = createCompliance().getData().getId(); |
| 60 | + Get2ComplianceJobsIdResponse result = apiInstance.compliance().getBatchComplianceJob(id).execute(); |
| 61 | + checkErrors(false, result.getErrors()); |
| 62 | + checkComplianceJobData(result.getData()); |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + public void getBatchComplianceJobErrorTest() throws ApiException { |
| 67 | + ApiException exception = assertThrows(ApiException.class, () -> { |
| 68 | + Get2ComplianceJobsIdResponse result = apiInstance.compliance().getBatchComplianceJob(complianceJobByIDNotFound).execute(); |
| 69 | + }); |
| 70 | + checkApiExceptionProblem(exception, InvalidRequestProblem.class, |
| 71 | + "The `id` query parameter value [" + complianceJobByIDNotFound + "] does not match ^[0-9]{1,19}$", |
| 72 | + "Invalid Request", "One or more parameters to your request was invalid."); |
| 73 | + } |
| 74 | + |
| 75 | +// ComplianceJobStatus should have "expired value |
| 76 | +// @Test |
| 77 | +// public void listBatchComplianceJobsTest() throws ApiException { |
| 78 | +// Get2ComplianceJobsResponse result = apiInstance.compliance().listBatchComplianceJobs( |
| 79 | +// CreateComplianceJobRequest.TypeEnum.TWEETS.getValue()).execute(); |
| 80 | +// checkErrors(false, result.getErrors()); |
| 81 | +// assertNotNull(result.getData()); |
| 82 | +// checkComplianceJobData(result.getData().get(0)); |
| 83 | +// } |
| 84 | + |
| 85 | + @Test |
| 86 | + public void listBatchComplianceJobsErrorTest() throws ApiException { |
| 87 | + ApiException exception = assertThrows(ApiException.class, () -> { |
| 88 | + apiInstance.compliance().listBatchComplianceJobs("DUMMY").execute(); |
| 89 | + }); |
| 90 | + checkApiExceptionProblem(exception, InvalidRequestProblem.class, |
| 91 | + "The `type` query parameter value [" + "DUMMY" + "] is not one of [tweets,users]", |
| 92 | + "Invalid Request", "One or more parameters to your request was invalid."); |
| 93 | + } |
| 94 | + |
| 95 | + @Test |
| 96 | + public void createBatchComplianceJobTest() throws ApiException { |
| 97 | + CreateComplianceJobResponse result = createCompliance(); |
| 98 | + checkErrors(false, result.getErrors()); |
| 99 | + assertNotNull(result.getData()); |
| 100 | + assertNotNull(result.getData().getId()); |
| 101 | + assertNotNull(result.getData().getType()); |
| 102 | + } |
| 103 | +} |
0 commit comments