Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/clickup/utils/ScenarioContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import clickup.entities.features.GetAllFeatures;

import java.util.HashMap;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;

public class ScenarioContext {
private Map<String, String> baseEnvironment;
private Map<String, GetAllFeatures> featuresAmount;
private Map<String, List> trash;
private Map<String, LinkedList> trash;
private static ScenarioContext instance;

public ScenarioContext() {
Expand Down Expand Up @@ -103,7 +103,7 @@ public GetAllFeatures getFeatures(final String key) {
* @param trashIdList that will contain the trash map
* @author Jorge Caceres
*/
public void setTrash(final String trashName, List<String> trashIdList) {
public void setTrash(final String trashName, LinkedList<String> trashIdList) {
if (getTrashList(trashName) == null) {
trash.put(trashName, trashIdList);
} else {
Expand All @@ -118,7 +118,7 @@ public void setTrash(final String trashName, List<String> trashIdList) {
* @return List stored on the map
* @author Jorge Caceres
*/
public List<String> getTrashList(String trashName) {
public LinkedList<String> getTrashList(String trashName) {
return trash.get(trashName);
}
}
11 changes: 5 additions & 6 deletions src/test/java/cucumber/hooks/TagsHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import io.cucumber.java.After;
import io.cucumber.java.Before;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;

public class TagsHooks {
private ApiRequestBuilder apiRequestBuilder;
Expand All @@ -36,7 +35,7 @@ public TagsHooks(ApiRequestBuilder apiRequestBuilder, ApiResponse apiResponse) {

@Before(value = "@DeleteTag")
public void createTag() {
List<String> tagsTrashList = new ArrayList<>();
LinkedList<String> tagsTrashList = new LinkedList<>();
String tagName = "deleteMe";
JSONObject jsonBody = new JSONObject();
JSONObject tagBody = new JSONObject();
Expand All @@ -52,12 +51,12 @@ public void createTag() {
ApiManager.execute(apiRequest, apiResponse);
apiResponse.getResponse().then().log().body();
tagsTrashList.add(tagName);
scenarioContext.setTrash("Tags Trash", tagsTrashList);
scenarioContext.setTrash("Tags", tagsTrashList);
}

@After(value = "@CreateTag")
public void deleteTags() {
List<String> tagsTrashList = scenarioContext.getTrashList("Tags Trash");
LinkedList<String> tagsTrashList = scenarioContext.getTrashList("Tags");
apiRequestBuilder
.endpoint(ApiEndpoints.DELETE_TAG.getEndpoint())
.pathParams("space_id", scenarioContext.getEnvData("space_id"))
Expand All @@ -68,6 +67,6 @@ public void deleteTags() {
ApiManager.execute(apiRequest, apiResponse);
apiResponse.getResponse().then().log().body();
}
scenarioContext.getTrashList("Tags Trash").clear();
scenarioContext.getTrashList("Tags").clear();
}
}
9 changes: 4 additions & 5 deletions src/test/java/cucumber/steps/AddTagsStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import core.api.ApiResponse;
import io.cucumber.java.en.When;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;

public class AddTagsStep {
private ApiRequestBuilder apiRequestBuilder = new ApiRequestBuilder();
Expand All @@ -31,7 +30,7 @@ public class AddTagsStep {

@When("I add the amount of {int} to the total of tags")
public void tagsBulkAdd(int amount) {
List<String> tagsTrashList = new ArrayList<>();
LinkedList<String> tagsTrashList = new LinkedList<>();
apiRequestBuilder
.baseUri(ApiHeaders.URL_BASE.getValue())
.headers(ApiHeaders.AUTHORIZATION.getValue(), System.getenv("API_TOKEN"))
Expand All @@ -48,8 +47,8 @@ public void tagsBulkAdd(int amount) {
apiRequest = apiRequestBuilder.build();
ApiManager.execute(apiRequest, apiResponse);
apiResponse.getResponse().then().log().body();
tagsTrashList.add(tagName);
tagsTrashList.addLast(tagName);
}
scenarioContext.setTrash("Tags Trash", tagsTrashList);
scenarioContext.setTrash("Tags", tagsTrashList);
}
}
38 changes: 38 additions & 0 deletions src/test/java/cucumber/steps/SetComposedEndpointStep.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cucumber.steps;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add copyrigth


import clickup.utils.ScenarioContext;
import core.api.ApiRequest;
import core.api.ApiRequestBuilder;
import core.api.ApiResponse;
import io.cucumber.java.en.Given;
import org.testng.asserts.SoftAssert;

import java.util.List;

import static clickup.utils.getPathParamsNames.getPathParamsFromEndpoint;

public class SetComposedEndpointStep {
private ApiRequestBuilder apiRequestBuilder;
private ApiRequest apiRequest;
private ApiResponse apiResponse;
private SoftAssert softAssert;
ScenarioContext scenarioContext = ScenarioContext.getInstance();

public SetComposedEndpointStep(ApiRequestBuilder apiRequestBuilder, ApiResponse apiResponse,
SoftAssert softAssert) {
this.apiRequestBuilder = apiRequestBuilder;
this.apiResponse = apiResponse;
this.softAssert = softAssert;
}

@Given("^I set the (.*) composed endpoint (.*)$")
public void setComposedEndpoint(final String featureName, final String endpoint) {
List<String> pathParamsList = getPathParamsFromEndpoint(endpoint);
apiRequestBuilder
.endpoint(endpoint)
.cleanParams();
apiRequestBuilder.pathParams(pathParamsList.get(0), scenarioContext.getEnvData(pathParamsList.get(0)))
.pathParams(pathParamsList.get(1), scenarioContext.getTrashList(featureName).getLast());

}
}
11 changes: 6 additions & 5 deletions src/test/java/cucumber/steps/SetTagBodyStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
import io.cucumber.java.en.When;
import org.json.JSONObject;
import org.testng.asserts.SoftAssert;
import java.util.ArrayList;
import java.util.List;
import java.util.LinkedList;
import java.util.Map;

public class SetTagBodyStep {
Expand All @@ -26,9 +25,11 @@ public SetTagBodyStep(ApiRequestBuilder apiRequestBuilder, ApiResponse apiRespon

@When("I set the tags body with following values:")
public void setTagBody(final Map<String, String> body) {
List<String> trashList = new ArrayList<>();
trashList.add(body.get("name"));
scenarioContext.setTrash("Tags Trash", trashList);
LinkedList<String> trashList = new LinkedList<>();
if (body.get("name") != null) {
trashList.addLast(body.get("name"));
scenarioContext.setTrash("Tags", trashList);
}
JSONObject jsonBody = new JSONObject();
JSONObject tagBody = new JSONObject();
for (String tagComponent: body.keySet()) {
Expand Down
18 changes: 18 additions & 0 deletions src/test/resources/features/tags/update_tag.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Update Tags

@CreateTag @DeleteTag
Scenario: As a user I want to update a Tag's name
Given I set the Tags composed endpoint /space/{space_id}/tag/{tag_name}
When I set the tags body with following values:
| name | Edited |
And I execute the PUT request for tags
Then I verify that the response status is 200

@CreateTag @DeleteTag
Scenario: As a user I want to update a Tag's color
Given I set the Tags composed endpoint /space/{space_id}/tag/{tag_name}
When I set the tags body with following values:
| tag_fg | #ffffff |
| tag_bg | #3c9d9b |
And I execute the PUT request for tags
Then I verify that the response status is 200