Revize b00ca083
Přidáno uživatelem Václav Hrabík před téměř 2 roky(ů)
src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/BaseTest.java | ||
---|---|---|
3 | 3 |
import cz.zcu.fav.kiv.antipatterndetectionapp.repository.AntiPatternRepository; |
4 | 4 |
import cz.zcu.fav.kiv.antipatterndetectionapp.service.AntiPatternService; |
5 | 5 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration; |
6 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Metadata; |
|
6 | 7 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.User; |
8 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.AboutPageRepository; |
|
7 | 9 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.ConfigRepository; |
8 | 10 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.repository.UserRepository; |
9 | 11 |
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.service.DetectionService; |
... | ... | |
43 | 45 |
@MockBean |
44 | 46 |
private ConfigRepository configurationRepository; |
45 | 47 |
|
48 |
@MockBean |
|
49 |
private AboutPageRepository aboutPageRepository; |
|
50 |
|
|
46 | 51 |
@BeforeEach |
47 | 52 |
public void init() { |
48 | 53 |
User user = new User("foo", "foo@foo.foo", "76D3BC41C9F588F7FCD0D5BF4718F8F84B1C41B20882703100B9EB9413807C01"); |
... | ... | |
100 | 105 |
configuration.add(con); |
101 | 106 |
when(configurationRepository.getAllUserConfigurations(config_user.getId())).thenReturn(configuration); |
102 | 107 |
|
108 |
/* About */ |
|
109 |
List<Metadata> metadata = new ArrayList<>(); |
|
110 |
Metadata met = new Metadata(); |
|
111 |
met.setAppDataValue("[ { \"version\": \"1.0.0\", \"authors\": [ { \"name\": \"Ondřej Váně\", \"email\": \"vaneo@students.zcu.cz\"}], \"description\": \"This application is used to detect presence of anti-patterns in project management tools data. Seven selected anti-patterns are implemented in this application.\"}, { \"version\": \"1.1.0\", \"authors\": [ { \"name\": \"Ondřej Váně\", \"email\": \"vaneo@students.zcu.cz\"}], \"description\": \"This application is used to detect presence of anti-patterns in project management tools data. Seven selected anti-patterns are implemented in this application.\"}, { \"version\": \"1.2.0\", \"authors\": [ { \"name\": \"Petr Štěpánek\", \"email\": \"petrs1@students.zcu.cz\"}], \"description\": \"This application is used to detect presence of anti-patterns in project management tools data. Ten selected anti-patterns are implemented in this application.\"}, { \"version\": \"2.0.0\", \"authors\": [ { \"name\": \"Petr Štěpánek\", \"email\": \"petrs1@students.zcu.cz\"}, { \"name\": \"Petr Urban\", \"email\": \"urbanp@students.zcu.cz\"}, { \"name\": \"Jiří Trefil\", \"email\": \"trefil@students.zcu.cz\"}, { \"name\": \"Václav Hrabík\", \"email\": \"hrabikv@students.zcu.cz\"}], \"description\": \"TODO\"}]"); |
|
112 |
met.setId(1L); |
|
113 |
met.setAppDataKey("basics"); |
|
114 |
metadata.add(met); |
|
115 |
when(aboutPageRepository.findAll()).thenReturn(metadata); |
|
116 |
|
|
103 | 117 |
RestAssuredMockMvc.webAppContextSetup(webApplicationContext); |
104 | 118 |
} |
105 | 119 |
|
src/test/resources/contracts/about_200.groovy | ||
---|---|---|
1 |
package contracts |
|
2 |
|
|
3 |
import org.springframework.cloud.contract.spec.Contract |
|
4 |
|
|
5 |
class Author { |
|
6 |
String name = "" |
|
7 |
String email = "" |
|
8 |
} |
|
9 |
|
|
10 |
class Version { |
|
11 |
String version = "" |
|
12 |
Author[] array = [] |
|
13 |
String description = "" |
|
14 |
} |
|
15 |
|
|
16 |
Contract.make { |
|
17 |
description "Get information about app." |
|
18 |
request { |
|
19 |
method GET() |
|
20 |
url("/v2/app/metadata/about") |
|
21 |
headers { |
|
22 |
header("Authorization": "Bearer token") |
|
23 |
contentType applicationJson() |
|
24 |
} |
|
25 |
} |
|
26 |
response { |
|
27 |
body( |
|
28 |
[["version" : '2.0.0', |
|
29 |
"authors": [["name": "Petr Štěpánek", "email": 'petrs1@students.zcu.cz'], |
|
30 |
["name": "Petr Urban", "email": 'urbanp@students.zcu.cz'], |
|
31 |
["name": "Jiří Trefil", "email": 'trefil@students.zcu.cz'], |
|
32 |
["name": "Václav Hrabík", "email": 'hrabikv@students.zcu.cz'] |
|
33 |
], |
|
34 |
"description": 'TODO'], |
|
35 |
["version": '1.2.0', |
|
36 |
"authors": [["name": 'Petr Štěpánek', "email": 'petrs1@students.zcu.cz']], |
|
37 |
"description": 'This application is used to detect presence of anti-patterns in project management tools data. Ten selected anti-patterns are implemented in this application.' |
|
38 |
], |
|
39 |
["version": '1.1.0', |
|
40 |
"authors": ["name": 'Ondřej Váně', "email": 'vaneo@students.zcu.cz'], |
|
41 |
"description": 'This application is used to detect presence of anti-patterns in project management tools data. Seven selected anti-patterns are implemented in this application.' |
|
42 |
], |
|
43 |
["version": '1.0.0', |
|
44 |
"authors": ["name": 'Ondřej Váně', "email": 'vaneo@students.zcu.cz'], |
|
45 |
"description": 'This application is used to detect presence of anti-patterns in project management tools data. Seven selected anti-patterns are implemented in this application.' |
|
46 |
] |
|
47 |
] |
|
48 |
) |
|
49 |
status 200 |
|
50 |
} |
|
51 |
} |
Také k dispozici: Unified diff
#10644 vytvoření groovy sriptů a namockování pro configurace