|
47 | 47 | public class APIM520UpdateAnAPIThroughThePublisherRestAPITestCase extends APIMIntegrationBaseTest {
|
48 | 48 |
|
49 | 49 | private final String apiNameTest = "APIM520PublisherTest";
|
| 50 | + private final String apiUpdatedNameTest = "PublisherTestRenameAPI"; |
| 51 | + private final String updatedApiName = "PublisherNewTestRenameAPI"; |
50 | 52 | private final String apiVersion = "1.0.0";
|
51 | 53 | private APIPublisherRestClient apiPublisher;
|
52 | 54 | private String apiProviderName;
|
@@ -138,6 +140,46 @@ public void testUpdateAnAPIThroughThePublisherRest() throws Exception {
|
138 | 140 |
|
139 | 141 | }
|
140 | 142 |
|
| 143 | + @Test(groups = {"wso2.am"}, description = "Update an API Through the Publisher Rest API after renaming the API") |
| 144 | + public void testUpdateAnAPIThroughThePublisherRestAfterRename() throws Exception { |
| 145 | + |
| 146 | + String apiContextTest = "apiRenamingContext"; |
| 147 | + String apiDescription = "This is Test API Created by API Manager Integration Test for API Renaming"; |
| 148 | + |
| 149 | + //Create an API |
| 150 | + APIRequest apiCreationRequestBean = new APIRequest(apiUpdatedNameTest, apiContextTest, |
| 151 | + new URL(apiProductionEndPointUrl)); |
| 152 | + apiCreationRequestBean.setVersion(apiVersion); |
| 153 | + apiCreationRequestBean.setProvider(apiProviderName); |
| 154 | + apiCreationRequestBean.setDescription(apiDescription); |
| 155 | + apiCreationRequestBean.setTiersCollection("Gold,Bronze"); |
| 156 | + |
| 157 | + HttpResponse apiCreationResponse = restAPIPublisher.addAPI(apiCreationRequestBean); |
| 158 | + id = apiCreationResponse.getData(); |
| 159 | + assertEquals(apiCreationResponse.getResponseCode(), Response.Status.CREATED.getStatusCode(), |
| 160 | + "Response Code miss matched when creating the API"); |
| 161 | + |
| 162 | + //Check availability of the API in publisher |
| 163 | + HttpResponse apiResponsePublisher = restAPIPublisher.getAPI(id); |
| 164 | + assertTrue(apiResponsePublisher.getData().contains(apiUpdatedNameTest), |
| 165 | + apiUpdatedNameTest + " is not visible in publisher"); |
| 166 | + |
| 167 | + //Update API with name change |
| 168 | + apiCreationRequestBean.setName(updatedApiName); |
| 169 | + |
| 170 | + HttpResponse apiUpdateResponse = restAPIPublisher.updateAPI(apiCreationRequestBean, id); |
| 171 | + assertEquals(apiUpdateResponse.getResponseCode(), Response.Status.OK.getStatusCode(), |
| 172 | + "Response Code miss matched when creating the API"); |
| 173 | + waitForAPIDeployment(); |
| 174 | + |
| 175 | + // Check whether API is updated from the above request. This API Name should not get updated |
| 176 | + // when not in a cloud scenario |
| 177 | + HttpResponse apiUpdateResponsePublisher = restAPIPublisher.getAPI(id); |
| 178 | + |
| 179 | + assertTrue(apiUpdateResponsePublisher.getData().contains(apiUpdatedNameTest), |
| 180 | + apiUpdatedNameTest + " is updated"); |
| 181 | + } |
| 182 | + |
141 | 183 | @AfterClass(alwaysRun = true)
|
142 | 184 | public void destroyAPIs() throws Exception {
|
143 | 185 | restAPIPublisher.deleteAPI(id);
|
|
0 commit comments