Skip to content

Commit

Permalink
request tests
Browse files Browse the repository at this point in the history
  • Loading branch information
l3r8yJ committed Feb 11, 2023
1 parent 808cda7 commit 431c83e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
34 changes: 26 additions & 8 deletions src/test/java/com/l3r8yj/elegramapi/request/TRqWithChatIdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

package com.l3r8yj.elegramapi.request;

import java.io.IOException;
import javax.ws.rs.core.Response;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -35,16 +38,31 @@
*/
final class TRqWithChatIdTest {

/**
* Under test request.
*/
private TelegramRequest request;

@BeforeEach
void setUp() {
this.request = new TRqWithChatId(
new TRqSendMessage("tkn"),
34
);
}

@Test
void responsesWithNotFound() throws IOException {
MatcherAssert.assertThat(
this.request.response().status(),
Matchers.equalTo(Response.Status.NOT_FOUND.getStatusCode())
);
}

@Test
void responsesFromRightUri() {
void createsUriWithRightParam() {
MatcherAssert.assertThat(
new TRqWithChatId(
new TRqSendMessage("tkn"),
34
)
.uri()
.toString()
.contains("chat_id=34"),
this.request.uri().toString().contains("chat_id=34"),
Matchers.equalTo(true)
);
}
Expand Down
12 changes: 11 additions & 1 deletion src/test/java/com/l3r8yj/elegramapi/request/TRqWithTextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package com.l3r8yj.elegramapi.request;

import java.io.IOException;
import javax.ws.rs.core.Response;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -50,10 +52,18 @@ void setUp() {
}

@Test
void responsesFromRightUri() {
void createsUriWithRightParam() {
MatcherAssert.assertThat(
this.request.uri().toString().contains("text="),
Matchers.equalTo(true)
);
}

@Test
void responsesWithNotFound() throws IOException {
MatcherAssert.assertThat(
this.request.response().status(),
Matchers.equalTo(Response.Status.NOT_FOUND.getStatusCode())
);
}
}

0 comments on commit 431c83e

Please sign in to comment.