Skip to content

Commit

Permalink
Move template to 1.1.7 version of JDI Dark
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-dukhov committed Nov 10, 2020
1 parent b12040a commit a5aa669
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
testRuntimeOnly(
'org.junit.jupiter:junit-jupiter-engine:5.4.0'
)
compile("com.epam.jdi:jdi-dark:1.0.3")
compile("com.epam.jdi:jdi-dark:1.1.7")
compile("org.slf4j:slf4j-nop:1.7.13")
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<dependency>
<groupId>com.epam.jdi</groupId>
<artifactId>jdi-dark</artifactId>
<version>1.0.3</version>
<version>1.1.7</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/com/epam/jdi/httptests/example/TrelloService.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.epam.jdi.httptests.example;

import com.epam.http.annotations.*;
import com.epam.http.requests.DataMethod;
import com.epam.http.requests.RestMethod;
import com.epam.http.requests.*;
import com.epam.jdi.httptests.example.dto.*;

import java.util.Arrays;
import java.util.List;

import static com.epam.http.requests.RequestDataFacrtory.pathParams;
import static io.restassured.http.ContentType.JSON;
import static java.util.Arrays.asList;

/**
* Example of service for working with Trello API (Service for Project Dashboard creating)
Expand All @@ -29,18 +27,18 @@ public class TrelloService {

@ContentType(JSON)
@POST(BOARDS)
public static DataMethod<Board> boardsPost;
public static RestDataMethod<Board> boardsPost;

public static Board createBoard(Board board) {
return boardsPost.callObject(board);
public static synchronized Board createBoard(Board board) {
return boardsPost.postAsData(board);
}

@ContentType(JSON)
@GET("/boards/{board_id}")
public static RestMethod getBoardById;

public static Board getBoard(String boardId) {
return getBoardById.call(pathParams().add("board_id", boardId)).getRaResponse().as(Board.class);
return getBoardById.call(RequestDataFactory.pathParams().add("board_id", boardId)).getRaResponse().as(Board.class);
}

@ContentType(JSON)
Expand Down Expand Up @@ -72,7 +70,7 @@ public static Card addNewCardToBoard(Card card) {
public static RestMethod getCardBoard;

public static Board getCardBoard(String cardId) {
return getCardBoard.call(pathParams().add("id", cardId)).getRaResponse().as(Board.class);
return getCardBoard.call(RequestDataFactory.pathParams().add("id", cardId)).getRaResponse().as(Board.class);
}

@ContentType(JSON)
Expand Down Expand Up @@ -109,7 +107,7 @@ public static Organization createOrganization(Organization organization) {
public static RestMethod getOrganizationBoards;

public static List<Board> getOrganizationBoards(Organization organization) {
return Arrays.asList(getOrganizationBoards.call(pathParams().add("id", organization.id)).getRaResponse().as(Board[].class));
return asList(getOrganizationBoards.call(RequestDataFactory.pathParams().add("id", organization.id)).getRaResponse().as(Board[].class));
}

}
21 changes: 8 additions & 13 deletions src/test/java/com/epam/jdi/httptests/example/ServiceTests.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package com.epam.jdi.httptests.example;

import com.epam.http.requests.RequestDataFactory;
import com.epam.http.requests.RestMethods;
import com.epam.http.response.RestResponse;
import org.junit.jupiter.api.*;

import static com.epam.http.requests.RequestDataFacrtory.cookies;
import static com.epam.http.requests.RequestDataFacrtory.pathParams;
import static com.epam.http.requests.RequestDataFacrtory.requestData;
import static com.epam.http.requests.RestMethods.GET;
import static com.epam.http.requests.ServiceInit.init;
import static com.epam.http.response.ResponseStatusType.SERVER_ERROR;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -37,10 +34,9 @@ public void simpleRestTest() {

@Test
public void noServiceObjectTest() {
RestResponse resp = GET(requestData(
rd -> {
RestResponse resp = RestMethods.GET(RequestDataFactory.requestData(rd -> {
rd.uri = "https://httpbin.org/get";
rd.addHeaders().addAll(new Object[][]{
rd.headerUpdater().addAll(new Object[][]{
{"Name", "Roman"},
{"Id", "TestTest"}
});
Expand All @@ -56,15 +52,14 @@ public void noServiceObjectTest() {

@Test
public void statusTestWithQueryInPath() {
RestResponse resp = service.statusWithQuery.callWithNamedParams("503", "some");
RestResponse resp = service.statusWithQuery.pathParams("503", "some").call();
assertEquals(resp.getStatus().code, 503);
assertEquals(resp.getStatus().type, SERVER_ERROR);
resp.isEmpty();
}

@Test
public void retryRequestTest(){
service.status.call(pathParams().add("status","500"))
public void retryRequestTest() {
service.status.call(RequestDataFactory.pathParams().add("status", "500"))
.assertThat()
.statusCode(500);
}
Expand All @@ -86,7 +81,7 @@ public void htmlBodyParseTest() {

@Test
public void cookiesTest() {
RestResponse response = service.getCookies.call(cookies().add("additionalCookie", "test"));
RestResponse response = service.getCookies.call(RequestDataFactory.cookies().add("additionalCookie", "test"));
response.isOk()
.body("cookies.additionalCookie", equalTo("test"))
.body("cookies.session_id", equalTo("1234"))
Expand Down

0 comments on commit a5aa669

Please sign in to comment.