Skip to content

Commit

Permalink
Update API import export test case
Browse files Browse the repository at this point in the history
Update API import export test case by adding documents to the API
  • Loading branch information
SavinduDimal committed Oct 16, 2023
1 parent fa4423e commit 8aef872
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.wso2.am.integration.clients.publisher.api.v1.dto.APIInfoDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.APIListDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.APIOperationsDTO;
import org.wso2.am.integration.clients.publisher.api.v1.dto.DocumentDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyDTO;
import org.wso2.am.integration.clients.store.api.v1.dto.ApplicationKeyGenerateRequestDTO;
Expand All @@ -59,6 +60,7 @@
import org.wso2.am.integration.test.utils.bean.APILifeCycleState;
import org.wso2.am.integration.test.utils.bean.APIRequest;
import org.wso2.am.integration.test.utils.bean.APIResourceBean;
import org.wso2.am.integration.test.utils.generic.TestConfigurationProvider;
import org.wso2.am.integration.test.utils.http.HTTPSClientUtils;
import org.wso2.am.integration.tests.api.lifecycle.APIManagerLifecycleBaseTest;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
Expand Down Expand Up @@ -200,6 +202,7 @@ public void setEnvironment() throws Exception {
}

createAndPublishAPI();
addDocument();

}

Expand Down Expand Up @@ -255,6 +258,33 @@ private void createAndPublishAPI() throws Exception {

}

private void addDocument() throws Exception {
String fileNameAPIM614 = "APIM614.txt";
String docName = "test-doc";
String summary = "test doc summary";
String filePathAPIM614 = TestConfigurationProvider.getResourceLocation() + File.separator + "artifacts" +
File.separator + "AM" + File.separator + "lifecycletest" + File.separator + fileNameAPIM614;
File file = new File(filePathAPIM614);

//Add document
DocumentDTO documentDTO = new DocumentDTO();
documentDTO.setName(docName);
documentDTO.setSummary(summary);
documentDTO.setType(DocumentDTO.TypeEnum.HOWTO);
documentDTO.setSourceType(DocumentDTO.SourceTypeEnum.FILE);
documentDTO.setVisibility(DocumentDTO.VisibilityEnum.API_LEVEL);
documentDTO.setName(docName);
HttpResponse documentationResponse = restAPIPublisher.addDocument(apiId, documentDTO);
assertEquals(documentationResponse.getResponseCode(), 200,
"Error while adding file-based documentation to API");
String fileTypeDocumentId = documentationResponse.getData();

//Update the document content
HttpResponse updateDocumentResponse = restAPIPublisher.updateContentDocument(apiId, fileTypeDocumentId, file);
assertEquals(updateDocumentResponse.getResponseCode(), 200,
"Error while updating documentation to API");
}

@Test(groups = { "wso2.am" }, description = "Exported Sample API with endpoint security enabled")
public void testAPIExport() throws Exception {

Expand Down

0 comments on commit 8aef872

Please sign in to comment.