-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathTopicControllerTest.java
More file actions
81 lines (70 loc) · 2.49 KB
/
TopicControllerTest.java
File metadata and controls
81 lines (70 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package org.ayfaar.app.controllers;
import org.apache.http.HttpStatus;
import org.ayfaar.app.Application;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.boot.test.WebIntegrationTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static com.jayway.restassured.RestAssured.given;
import static com.jayway.restassured.RestAssured.when;
@RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("dev")
@SpringApplicationConfiguration(Application.class)
@WebIntegrationTest
public class TopicControllerTest {
@Test
public void testGet() {
when().
get("/api/topic/{name}/add-child/{child}", "1", "2").
then()
.log().all().
statusCode(HttpStatus.SC_OK);
// todo добавить ещё чайлда "3" и парента "4"
when().
get("/api/topic/{name}", "1").
then().
log().all().
statusCode(HttpStatus.SC_OK).
body("name", Matchers.is("1")).
body("uri", Matchers.is("тема:1")).
body("children", Matchers.hasItems("3", "2")).
body("parents", Matchers.hasItem("4"))
;
}
@Test
public void testAddFor() {
given().
contentType("application/x-www-form-urlencoded; charset=UTF-8"). // это чтобы русский понимал в параметрах
param("name", "1"). // имя темы
param("uri", "видео:youtube:_8vYBLrOq-w"). // uri объекта к которому прилинковать тему
when().
post("/api/topic/for").
then().
log().all().
statusCode(HttpStatus.SC_OK)
;
}
@Test
public void testAddChild() {
when().
get("/api/topic/{name}/add-child/{child}", "1", "2").
then().
log().all().
statusCode(HttpStatus.SC_OK)
;
}
@Test
public void testUnLink() {
// сначала прилинковываем
when().get("/api/topic/{name}/add-child/{child}", "1", "2").then().statusCode(HttpStatus.SC_OK);
when().
get("/api/topic/{name}/unlink/{linked}", "1", "2").
then().
log().all().
statusCode(HttpStatus.SC_OK)
;
}
}