Skip to content

Commit

Permalink
- fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Dec 19, 2023
1 parent 8ccdfc9 commit b84a6bb
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio
$(http().client(apiManager).send().post("/applications").message().header("Content-Type", "application/json")
.body("{\"name\":\"${app1Name}\",\"apis\":[],\"organizationId\":\"${orgId}\"}"));

$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).extract(fromBody()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).extract(fromBody()
.expression("$.id", "consumingTestApp1Id")
.expression("$.name", "consumingTestApp1Name")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -30,7 +29,6 @@ public class DuplicateApplicationSubscriptionTestIT extends TestNGCitrusSpringSu

@CitrusTest
@Test
@Parameters("context")
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Verify subscription handling, if App isn't unique based on the name (See issue #217)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void run() {
.header("Content-Type", "application/json")
.body("{\"name\":\"${testAppName}\",\"apis\":[],\"organizationId\":\"${orgId}\"}"));

$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).extract(fromBody()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).extract(fromBody()
.expression("$.id", "testAppId")
.expression("$.name", "testAppName")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,28 @@ public void run() {

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${orgName1}\", \"description\": \"Org 1 without dev permission\", \"enabled\": true, \"development\": false }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${orgName1}"))
.extract(fromBody()
.expression("$.id", "orgId1")));

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${orgName2}\", \"description\": \"Org 2 without dev permission\", \"enabled\": true, \"development\": false }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${orgName2}"))
.extract(fromBody()
.expression("$.id", "orgId2")));

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${orgName3}\", \"description\": \"Org 3 without dev permission\", \"enabled\": true, \"development\": false }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${orgName3}"))
.extract(fromBody()
.expression("$.id", "orgId3")));

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${orgName4}\", \"description\": \"Org 4 without dev permission\", \"enabled\": true, \"development\": false }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${orgName4}"))
.extract(fromBody()
.expression("$.id", "orgId4")));
Expand All @@ -81,28 +81,28 @@ public void run() {

$(http().client(apiManager).send().post("/applications").message().header("Content-Type", "application/json")
.body("{\"name\":\"${appName1}\",\"apis\":[],\"organizationId\":\"${orgId1}\"}"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${appName1}"))
.extract(fromBody()
.expression("$.id", "appId1")));

$(http().client(apiManager).send().post("/applications").message().header("Content-Type", "application/json")
.body("{\"name\":\"${appName2}\",\"apis\":[],\"organizationId\":\"${orgId2}\"}"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${appName2}"))
.extract(fromBody()
.expression("$.id", "appId2")));

$(http().client(apiManager).send().post("/applications").message().header("Content-Type", "application/json")
.body("{\"name\":\"${appName3}\",\"apis\":[],\"organizationId\":\"${orgId3}\"}"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${appName3}"))
.extract(fromBody()
.expression("$.id", "appId3")));

$(http().client(apiManager).send().post("/applications").message().header("Content-Type", "application/json")
.body("{\"name\":\"${appName4}\",\"apis\":[],\"organizationId\":\"${orgId4}\"}"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${appName4}"))
.extract(fromBody()
.expression("$.id", "appId4")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void run() {
variable("appName2", "App in ungranted org ${apiNumber}");
$(http().client(apiManager).send().post("/applications").name("orgCreatedRequest").message().header("Content-Type", "application/json")
.body("{\"name\":\"${appName1}\",\"apis\":[],\"organizationId\":\"${orgId}\"}"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).extract(fromBody()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).extract(fromBody()
.expression("$.id", "testAppId1")
.expression("$.name", "testAppName1")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run() {

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${orgName1}\", \"description\": \"Org 1 without dev permission\", \"enabled\": true, \"development\": false }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${orgName1}")).extract(fromBody()
.expression("$.id", "orgId1")));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -35,7 +34,7 @@ public class BackToPublishedFromDeprecatedTestIT extends TestNGCitrusSpringSuppo
HttpClient apiManager;

@CitrusTest
@Test @Parameters("context")
@Test
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Once an API in status deprecated, it must be possible to go back to published, basically remove the deperation status");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -29,7 +28,6 @@ public class SwaggerFromFileInConfigurationTestIT extends TestNGCitrusSpringSupp

@CitrusTest
@Test
@Parameters("context")
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Validates a Swagger-File can be taken from a file path described in json configuration file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -28,7 +27,7 @@ public class SwaggerFromURLRefFileInConfigurationTestIT extends TestNGCitrusSpri
HttpClient apiManager;

@CitrusTest
@Test @Parameters("context")
@Test
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Validates a Swagger-File can be taken from a URL using a REF-File described in API json configuration");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -29,7 +28,7 @@ public class UnpublishedSummaryAPITestIT extends TestNGCitrusSpringSupport {
HttpClient apiManager;

@CitrusTest
@Test @Parameters("context")
@Test
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Make sure, the summary gets updated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.citrusframework.testng.spring.TestNGCitrusSpringSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -24,7 +23,7 @@ public class InboundMethodLevelInvalidOperationTestIT extends TestNGCitrusSpring
HttpClient apiManager;

@CitrusTest
@Test @Parameters("context")
@Test
public void run() throws IOException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Make sure, the error that an invalid operationId is given is properly handled.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public void run() {
$(http().client(apiManager).send().get("/proxies"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.[?(@.path=='${apiPath}')].name", "${apiName}")
.expression("$.[?(@.path=='${apiPath}')].state", "published")
.expression("$.[?(@.path=='${apiPath}')].id", "apiId")));

.expression("$.[?(@.path=='${apiPath}')].state", "published")));
$(echo("####### Validate second org has no permission #######"));
$(http().client(apiManager).send().get("/organizations/${noPermOrgId}/apis"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

import java.io.IOException;
Expand All @@ -31,7 +30,6 @@ public class APIBasicQuotaTestIT extends TestNGCitrusSpringSupport {

@CitrusTest
@Test
@Parameters("context")
public void run() throws IOException, InterruptedException {
ImportTestAction swaggerImport = new ImportTestAction();
description("Import an API containing a quota definition");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run(@Optional @CitrusResource TestContext context) throws IOExceptio

$(http().client(apiManager).send().post("/organizations").message().header("Content-Type", "application/json")
.body("{\"name\": \"${vhostOrgName}\", \"description\": \"Org 1 with dev permission and VHost\", \"enabled\": true, \"development\": true, \"virtualHost\": \"${vhost}\" }"));
$(http().client(apiManager).receive().response(HttpStatus.OK).message().type(MessageType.JSON).validate(jsonPath()
$(http().client(apiManager).receive().response(HttpStatus.CREATED).message().type(MessageType.JSON).validate(jsonPath()
.expression("$.name", "${vhostOrgName}")).extract(fromBody()
.expression("$.id", "vhostOrgId")));

Expand Down

0 comments on commit b84a6bb

Please sign in to comment.