forked from kamax-matrix/matrix-java-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatrixHttpUserWiremockTest.java
92 lines (75 loc) · 3.23 KB
/
MatrixHttpUserWiremockTest.java
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
82
83
84
85
86
87
88
89
90
91
92
/*
* matrix-java-sdk - Matrix Client SDK for Java
* Copyright (C) 2017 Arne Augenstein
*
* https://max.kamax.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package io.kamax.matrix;
import org.junit.Test;
import java.net.URISyntaxException;
import static com.github.tomakehurst.wiremock.client.WireMock.*;
public class MatrixHttpUserWiremockTest extends AMatrixHttpUserTest {
private String nameUrl = String.format("/_matrix/client/r0/profile/%s/displayname", user.getId()) + tokenParameter;
private String nameResponse = String.format("{\"displayname\": \"%s\"}", username);
private String avatarUrl = String.format("/_matrix/client/r0/profile/%s/avatar_url", user.getId()) + tokenParameter;
private String avatarResponse = String.format("{\"avatar_url\": \"%s\"}", avatarMediaUrl);
@Override
public void login() throws URISyntaxException {
}
@Override
public void logout() {
}
@Test
public void getName() throws URISyntaxException {
stubFor(get(urlEqualTo(nameUrl)).willReturn(aResponse().withStatus(200).withBody(nameResponse)));
super.getName();
}
@Test
public void getName404() throws URISyntaxException {
stubFor(get(urlEqualTo(nameUrl)).willReturn(aResponse().withStatus(404).withBody(error404Response)));
super.getName404();
}
@Test
public void getNameError403() throws URISyntaxException {
stubFor(get(urlEqualTo(nameUrl)).willReturn(aResponse().withStatus(403).withBody(error403Response)));
super.getNameError403();
}
@Test
public void getNameError429() throws URISyntaxException {
stubFor(get(urlEqualTo(nameUrl)).willReturn(aResponse().withStatus(429).withBody(error429Response)));
super.getNameError429();
}
@Test
public void getAvatar() throws URISyntaxException {
stubFor(get(urlEqualTo(avatarUrl)).willReturn(aResponse().withStatus(200).withBody(avatarResponse)));
super.getAvatar();
}
@Test
public void getAvatar404() throws URISyntaxException {
stubFor(get(urlEqualTo(avatarUrl)).willReturn(aResponse().withStatus(404).withBody(error404Response)));
super.getAvatar404();
}
@Test
public void getAvatarError403() throws URISyntaxException {
stubFor(get(urlEqualTo(avatarUrl)).willReturn(aResponse().withStatus(403).withBody(error403Response)));
super.getAvatarError403();
}
@Test
public void getAvatarError429() throws URISyntaxException {
stubFor(get(urlEqualTo(avatarUrl)).willReturn(aResponse().withStatus(429).withBody(error429Response)));
super.getAvatarError429();
}
}