Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1e098a8b

Přidáno uživatelem Václav Hrabík před téměř 2 roky(ů)

#10646 vytvoření groovy sriptů a namockování pro configurace

Zobrazit rozdíly:

src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/v2/controller/BaseTest.java
1 1
package cz.zcu.fav.kiv.antipatterndetectionapp.v2.controller;
2 2

  
3
import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.AntiPatternManager;
4
import cz.zcu.fav.kiv.antipatterndetectionapp.detecting.detectors.AntiPatternDetector;
5
import cz.zcu.fav.kiv.antipatterndetectionapp.model.*;
3 6
import cz.zcu.fav.kiv.antipatterndetectionapp.repository.AntiPatternRepository;
7
import cz.zcu.fav.kiv.antipatterndetectionapp.repository.ProjectRepository;
4 8
import cz.zcu.fav.kiv.antipatterndetectionapp.service.AntiPatternService;
5 9
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Configuration;
6 10
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.model.Metadata;
......
12 16
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.JSONBuilder;
13 17
import cz.zcu.fav.kiv.antipatterndetectionapp.v2.utils.RequestBuilder;
14 18
import io.restassured.module.mockmvc.RestAssuredMockMvc;
19
import org.junit.jupiter.api.BeforeAll;
15 20
import org.junit.jupiter.api.BeforeEach;
16 21
import org.springframework.beans.factory.annotation.Autowired;
17 22
import org.springframework.boot.test.context.SpringBootTest;
......
40 45
    private RequestBuilder requestBuilder;
41 46

  
42 47
    @MockBean
43
    private AntiPatternRepository antiPatternRepository;
48
    private AntiPatternService antiPatternService;
44 49

  
45 50
    @MockBean
46 51
    private ConfigRepository configurationRepository;
......
48 53
    @MockBean
49 54
    private AboutPageRepository aboutPageRepository;
50 55

  
56
    @MockBean
57
    private AntiPatternManager antiPatternManager;
58

  
59
    @MockBean
60
    private ProjectRepository projectRepository;
61

  
51 62
    @BeforeEach
52 63
    public void init() {
64

  
65
        setupUserControllerMocks();
66
        setupFilterMocks();
67
        setupConfigurationControllerMocks();
68
        setupAboutControllerMocks();
69
        setupDetectionControllerMocks();
70

  
71
        RestAssuredMockMvc.webAppContextSetup(webApplicationContext);
72
    }
73

  
74
    private void setupUserControllerMocks() {
53 75
        User user = new User("foo", "foo@foo.foo", "76D3BC41C9F588F7FCD0D5BF4718F8F84B1C41B20882703100B9EB9413807C01");
54 76
        User userWrongPassword = new User("foo", "foo@foo.foo", "foo");
55 77
        ResponseEntity<String> loginResponse = ResponseEntity.ok("token");
56 78

  
57

  
58 79
        /* Registration of user */
59 80
        when(userRepository.findByName("new_user")).thenReturn(null);
60 81
        when(userRepository.findByName("existing")).thenReturn(user);
......
66 87
        when(userRepository.findByName("non_existing")).thenReturn(null);
67 88
        when(userRepository.findByName("foo")).thenReturn(userWrongPassword);
68 89

  
90
        /* Logout of user */
91
        Map<String,Object> logoutJson = new HashMap<>();
92
        logoutJson.put("message", "User logged out");
93
        String logoutBody = JSONBuilder.buildJSON(logoutJson);
94
        ResponseEntity<String> logoutResponse = ResponseEntity.ok(logoutBody);
95
        when(requestBuilder.sendRequestResponse(eq("http://localhost:8081/logout"), anyMap())).thenReturn(logoutResponse);
96
    }
97

  
98
    private void setupFilterMocks() {
69 99
        /* Filter mock */
70 100
        Map<String,Object> filterJson = new HashMap<>();
71 101
        filterJson.put("message", "User authorized");
......
78 108
        String filterBody2 = JSONBuilder.buildJSON(filterJson2);
79 109
        ResponseEntity<String> oauth2 = ResponseEntity.status(500).body(filterBody2);
80 110
        when(requestBuilder.sendRequestResponse(anyString(), eq("wrong"))).thenReturn(oauth2);
111
    }
81 112

  
82
        /* Logout of user */
83
        Map<String,Object> logoutJson = new HashMap<>();
84
        logoutJson.put("message", "User logged out");
85
        String logoutBody = JSONBuilder.buildJSON(logoutJson);
86
        ResponseEntity<String> logoutResponse = ResponseEntity.ok(logoutBody);
87
        when(requestBuilder.sendRequestResponse(eq("http://localhost:8081/logout"), anyMap())).thenReturn(logoutResponse);
88

  
89
        /* Configuration */
113
    private void setupConfigurationControllerMocks() {
90 114
        /* /configuration_name */
91 115
        User config_user = new User("config_user");
92 116
        config_user.setId(1);
......
98 122
        configs.add(pom_pole);
99 123
        when(configurationRepository.getAllUserConfigurationNames(config_user.getId())).thenReturn(configs);
100 124

  
101
        /* configuration */
125
        /* /configuration */
102 126
        List<Configuration> configuration = new ArrayList<>();
103 127
        Configuration con = new Configuration("{\r\n    \"configuration\": [\r\n        {\r\n            \"antiPattern\": \"TooLongSprint\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxIterationLength\",\r\n                    \"value\": \"21\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxNumberOfTooLongIterations\",\r\n                    \"value\": \"0\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"VaryingSprintLength\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxDaysDifference\",\r\n                    \"value\": \"7\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxIterationChanged\",\r\n                    \"value\": \"1\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"BusinessAsUsual\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"divisionOfIterationsWithRetrospective\",\r\n                    \"value\": \"66.66f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithRetrospective\",\r\n                    \"value\": \"%retr%||%revi%||%week%scrum%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"SpecifyNothing\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"minNumberOfWikiPagesWithSpecification\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minNumberOfActivitiesWithSpecification\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minAvgLengthOfActivityDescription\",\r\n                    \"value\": \"150\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithProjectSpecification\",\r\n                    \"value\": \"%dsp%||%specifikace%||%specification%||%vize%proj%||%vize%produ%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"RoadToNowhere\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"minNumberOfWikiPagesWithProjectPlan\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minNumberOfActivitiesWithProjectPlan\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithProjectPlan\",\r\n                    \"value\": \"%pl?n projektu%||%project plan%||%plan project%||%projektov? pl?n%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"LongOrNonExistentFeedbackLoops\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"divisionOfIterationsWithFeedbackLoop\",\r\n                    \"value\": \"50.00f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxGapBetweenFeedbackLoopRate\",\r\n                    \"value\": \"2f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithFeedbackLoop\",\r\n                    \"value\": \"%sch?z%z?kazn?k%||%p?edveden?%z?kazn?k%||%z?kazn%demo%||%sch?z%zadavat%||%inform%sch?z%||%z?kazn%||%zadavatel%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"NinetyNinetyRule\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxDivisionRange\",\r\n                    \"value\": \"1.25f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxBadDivisionLimit\",\r\n                    \"value\": \"2\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"UnknownPoster\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsInvalidNames\",\r\n                    \"value\": \"%unknown%||%anonym%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"BystanderApathy\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsInvalidContributors\",\r\n                    \"value\": \"%dependabot%\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maximumPercentageOfTasksWithoutTeamwork\",\r\n                    \"value\": \"30f\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"YetAnotherProgrammer\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxNumberOfNewContributors\",\r\n                    \"value\": \"5\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"numberOfFirstMonthsWithoutDetection\",\r\n                    \"value\": \"2\"\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}"
104
        , "Y", "default_config");
128
                , "Y", "default_config");
105 129
        configuration.add(con);
106 130
        when(configurationRepository.getAllUserConfigurations(config_user.getId())).thenReturn(configuration);
131
    }
107 132

  
108
        /* About */
133
    private void setupAboutControllerMocks() {
109 134
        List<Metadata> metadata = new ArrayList<>();
110 135
        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\"}]");
136
        met.setAppDataValue("[ { \"version\": \"1.0.0\", \"authors\": [ { \"name\": \"Ondrej Vane\", \"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\": \"Ondrej Vane\", \"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 Stepanek\", \"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 Stepanek\", \"email\": \"petrs1@students.zcu.cz\"}, { \"name\": \"Petr Urban\", \"email\": \"urbanp@students.zcu.cz\"}, { \"name\": \"Jiri Trefil\", \"email\": \"trefil@students.zcu.cz\"}, { \"name\": \"Vaclav Hrabik\", \"email\": \"hrabikv@students.zcu.cz\"}], \"description\": \"TODO\"}]");
112 137
        met.setId(1L);
113 138
        met.setAppDataKey("basics");
114 139
        metadata.add(met);
115 140
        when(aboutPageRepository.findAll()).thenReturn(metadata);
116

  
117
        RestAssuredMockMvc.webAppContextSetup(webApplicationContext);
118 141
    }
119 142

  
143
    private void setupDetectionControllerMocks() {
144
        /* Detection */
145
        /* /list */
146
        Map<String, Threshold> thresholdMap1 = new HashMap<>();
147
        thresholdMap1.put("divisionOfIterationsWithRetrospective", new Threshold(
148
                "divisionOfIterationsWithRetrospective",
149
                "Division of iterations with retrospective",
150
                "Minimum percentage of the total number of iterations with a retrospective (0,100)",
151
                "Percentage must be float number between 0 and 100",
152
                "Percentage"
153
        ));
154
        thresholdMap1.put("searchSubstringsWithRetrospective", new Threshold(
155
                "searchSubstringsWithRetrospective",
156
                "Search substrings with retrospective",
157
                "Substring that will be search in wikipages and activities",
158
                "Maximum number of substrings is ten and must not starts and ends with characters || ",
159
                "String"
160
        ));
161
        List<AntiPattern> antiPatterns = new ArrayList<>();
162
        antiPatterns.add(new AntiPattern(3L,
163
                "Business As Usual",
164
                "BusinessAsUsual",
165
                "Absence of a retrospective after individual iterations or after the completion project.",
166
                thresholdMap1,
167
                "Business_As_Usual.md"
168
        ));
169
        when(antiPatternService.antiPatternsToModel(any())).thenReturn(antiPatterns);
170

  
171
        List<Project> projectList = new ArrayList<>();
172
        Project project1 = new Project("Aplikace nad otevrenymi daty (KIV) BHVS", "generic description in czech");
173
        project1.setId(6L);
174
        projectList.add(project1);
175
        when(projectRepository.findAll()).thenReturn(projectList);
176

  
177
        /* /detect */
178
        Configuration con = new Configuration("{\r\n    \"configuration\": [\r\n        {\r\n            \"antiPattern\": \"TooLongSprint\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxIterationLength\",\r\n                    \"value\": \"21\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxNumberOfTooLongIterations\",\r\n                    \"value\": \"0\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"VaryingSprintLength\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxDaysDifference\",\r\n                    \"value\": \"7\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxIterationChanged\",\r\n                    \"value\": \"1\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"BusinessAsUsual\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"divisionOfIterationsWithRetrospective\",\r\n                    \"value\": \"66.66f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithRetrospective\",\r\n                    \"value\": \"%retr%||%revi%||%week%scrum%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"SpecifyNothing\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"minNumberOfWikiPagesWithSpecification\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minNumberOfActivitiesWithSpecification\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minAvgLengthOfActivityDescription\",\r\n                    \"value\": \"150\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithProjectSpecification\",\r\n                    \"value\": \"%dsp%||%specifikace%||%specification%||%vize%proj%||%vize%produ%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"RoadToNowhere\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"minNumberOfWikiPagesWithProjectPlan\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"minNumberOfActivitiesWithProjectPlan\",\r\n                    \"value\": \"1\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithProjectPlan\",\r\n                    \"value\": \"%pl?n projektu%||%project plan%||%plan project%||%projektov? pl?n%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"LongOrNonExistentFeedbackLoops\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"divisionOfIterationsWithFeedbackLoop\",\r\n                    \"value\": \"50.00f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxGapBetweenFeedbackLoopRate\",\r\n                    \"value\": \"2f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsWithFeedbackLoop\",\r\n                    \"value\": \"%sch?z%z?kazn?k%||%p?edveden?%z?kazn?k%||%z?kazn%demo%||%sch?z%zadavat%||%inform%sch?z%||%z?kazn%||%zadavatel%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"NinetyNinetyRule\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxDivisionRange\",\r\n                    \"value\": \"1.25f\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maxBadDivisionLimit\",\r\n                    \"value\": \"2\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"UnknownPoster\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsInvalidNames\",\r\n                    \"value\": \"%unknown%||%anonym%\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"BystanderApathy\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"searchSubstringsInvalidContributors\",\r\n                    \"value\": \"%dependabot%\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"maximumPercentageOfTasksWithoutTeamwork\",\r\n                    \"value\": \"30f\"\r\n                }\r\n            ]\r\n        },\r\n        {\r\n            \"antiPattern\": \"YetAnotherProgrammer\",\r\n            \"thresholds\": [\r\n                {\r\n                    \"thresholdName\": \"maxNumberOfNewContributors\",\r\n                    \"value\": \"5\"\r\n                },\r\n                {\r\n                    \"thresholdName\": \"numberOfFirstMonthsWithoutDetection\",\r\n                    \"value\": \"2\"\r\n                }\r\n            ]\r\n        }\r\n    ]\r\n}"
179
                , "Y", "default_config");
180
        String[] selectedProjects = new String[1];
181
        selectedProjects[0] = "1";
182
        String[] selectedAntiPatterns = new String[1];
183
        selectedAntiPatterns[0] = "3";
184
        Map<String, Map<String,String>> currentConfiguration = JSONBuilder.createMapFromString(con.getConfig());
185
        when(configurationRepository.findConfigurationById(1)).thenReturn(con);
186
        Project project = new Project("Aplikace pro Centrum blizkovychodnich studii (FF) Medici", "");
187
        project.setId(1L);
188
        List<QueryResult> results = new ArrayList<>();
189
            List<QueryResultItem> queryResultItemList = new ArrayList<>();
190
                List<ResultDetail> resultDetailsList = new ArrayList<>();
191
                    resultDetailsList.add(new ResultDetail("Min retrospective limit", "3"));
192
                    resultDetailsList.add(new ResultDetail("Found retrospectives", "4"));
193
                    resultDetailsList.add(new ResultDetail("Total number of iterations", "5"));
194
                    resultDetailsList.add(new ResultDetail("Conclusion", "There is right number of retrospectives"));
195
            queryResultItemList.add(new QueryResultItem(antiPatterns.get(0), false, resultDetailsList));
196
        results.add(new QueryResult(project, queryResultItemList));
197
        when(antiPatternManager.analyze(selectedProjects, selectedAntiPatterns, currentConfiguration)).thenReturn(results);
198
    }
120 199
}
src/test/resources/contracts/about_200.groovy
26 26
    response {
27 27
        body(
28 28
               [["version" : '2.0.0',
29
                 "authors": [["name": "Petr Štěpánek", "email": 'petrs1@students.zcu.cz'],
29
                 "authors": [["name": "Petr Stepanek", "email": 'petrs1@students.zcu.cz'],
30 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']
31
                             ["name": "Jiri Trefil", "email": 'trefil@students.zcu.cz'],
32
                             ["name": "Vaclav Hrabik", "email": 'hrabikv@students.zcu.cz']
33 33
                            ],
34 34
                 "description": 'TODO'],
35 35
                ["version": '1.2.0',
36
                 "authors": [["name": 'Petr Štěpánek', "email": 'petrs1@students.zcu.cz']],
36
                 "authors": [["name": 'Petr Stepanek', "email": 'petrs1@students.zcu.cz']],
37 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 38
                ],
39 39
                ["version": '1.1.0',
40
                 "authors": ["name": 'Ondřej Váně', "email": 'vaneo@students.zcu.cz'],
40
                 "authors": ["name": 'Ondrej Vane', "email": 'vaneo@students.zcu.cz'],
41 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 42
                ],
43 43
                ["version": '1.0.0',
44
                 "authors": ["name": 'Ondřej Váně', "email": 'vaneo@students.zcu.cz'],
44
                 "authors": ["name": 'Ondrej Vane', "email": 'vaneo@students.zcu.cz'],
45 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 46
                ]
47
                ]
47
               ]
48 48
        )
49 49
        status 200
50 50
    }
src/test/resources/contracts/detectAntiPatternsInProjects_200.groovy
1
package contracts
2

  
3
import org.springframework.cloud.contract.spec.Contract
4

  
5
Contract.make {
6
    description "Fetch all configurations of user."
7
    request {
8
        method POST()
9
        url("/v2/detect/analyze")
10
        headers {
11
            header("Authorization": "Bearer token")
12
            contentType applicationJson()
13
        }
14
        body(
15
                "configurationId" : "1",
16
                "selectedAntipatterns" : [3],
17
                "selectedProjects" : [1]
18
        )
19
    }
20
    response {
21
        body(
22
            [
23
                    [
24
                            "project" : [
25
                                    "description" : "",
26
                                    "id" : 1,
27
                                    "name" : "Aplikace pro Centrum blizkovychodnich studii (FF) Medici"
28
                            ],
29
                            "queryResultItems" : [
30
                                        ["antiPattern" : ["catalogueFileName" : "Business_As_Usual.md",
31
                                                         "description" : "Absence of a retrospective after individual iterations or after the completion project.",
32
                                                         "id" : 3,
33
                                                         "name" : "BusinessAsUsual",
34
                                                         "printName" : "Business As Usual",
35
                                                         "thresholds" : ["divisionOfIterationsWithRetrospective" : ["description" : "Minimum percentage of the total number of iterations with a retrospective (0,100)",
36
                                                                                                                    "errorMessage" : "Percentage must be float number between 0 and 100",
37
                                                                                                                    "isErrorMessageShown" : false,
38
                                                                                                                    "name" : "divisionOfIterationsWithRetrospective",
39
                                                                                                                    "printName" : "Division of iterations with retrospective",
40
                                                                                                                    "type" : "Percentage"
41
                                                         ],
42
                                                                         "searchSubstringsWithRetrospective" : ["description" : "Substring that will be search in wikipages and activities",
43
                                                                                                                "errorMessage" : "Maximum number of substrings is ten and must not starts and ends with characters || ",
44
                                                                                                                "isErrorMessageShown" : false,
45
                                                                                                                "name" : "searchSubstringsWithRetrospective",
46
                                                                                                                "printName" : "Search substrings with retrospective",
47
                                                                                                                "type" : "String"
48
                                                                         ]
49
                                                         ]
50
                                        ],
51
                                        "isDetected" : false,
52
                                        "resultDetails" : [
53
                                                [
54
                                                        "resultDetailName" : "Min retrospective limit",
55
                                                        "resultDetailValue" : "3"
56
                                                ],
57
                                                [
58
                                                        "resultDetailName" : "Found retrospectives",
59
                                                        "resultDetailValue" : "4"
60
                                                ],
61
                                                [
62
                                                        "resultDetailName" : "Total number of iterations",
63
                                                        "resultDetailValue" : "5"
64
                                                ],
65
                                                [
66
                                                        "resultDetailName" : "Conclusion",
67
                                                        "resultDetailValue" : "There is right number of retrospectives"
68
                                                ]
69
                                        ]
70
                                        ]
71
                            ]
72
                    ]
73
            ]
74
        )
75
        status 200
76
    }
77
}
78

  
src/test/resources/contracts/listAllProjectsAllAntiPatterns_200.groovy
1
package contracts
2

  
3
import org.springframework.cloud.contract.spec.Contract
4

  
5
Contract.make {
6
    description "Fetch all configurations of user."
7
    request {
8
        method GET()
9
        url("/v2/detect/list")
10
        headers {
11
            header("Authorization": "Bearer token")
12
            contentType applicationJson()
13
        }
14
    }
15
    response {
16
        body(
17
                "antiPatterns": [
18
                    ["catalogueFileName" : "Business_As_Usual.md",
19
                     "description" : "Absence of a retrospective after individual iterations or after the completion project.",
20
                     "id" : 3,
21
                     "name" : "BusinessAsUsual",
22
                     "printName" : "Business As Usual",
23
                     "thresholds" :     ["divisionOfIterationsWithRetrospective" :
24
                                                    [    "description" : "Minimum percentage of the total number of iterations with a retrospective (0,100)",
25
                                                         "errorMessage" : "Percentage must be float number between 0 and 100",
26
                                                         "isErrorMessageShown" : false,
27
                                                         "name" : "divisionOfIterationsWithRetrospective",
28
                                                         "printName" : "Division of iterations with retrospective",
29
                                                         "type" : "Percentage"
30
                                                    ],
31
                                         "searchSubstringsWithRetrospective" :
32
                                                    [    "description" : "Substring that will be search in wikipages and activities",
33
                                                         "errorMessage" : "Maximum number of substrings is ten and must not starts and ends with characters || ",
34
                                                         "isErrorMessageShown" : false,
35
                                                         "name" : "searchSubstringsWithRetrospective",
36
                                                         "printName" : "Search substrings with retrospective",
37
                                                         "type" : "String"
38
                                                    ]
39
                                        ]
40
                    ]
41
                ],
42
                "projects" : [
43
                        [
44
                                "description" : "generic description in czech",
45
                                "id" : 6,
46
                                "name" : "Aplikace nad otevrenymi daty (KIV) BHVS"
47
                        ]
48
                ]
49

  
50
        )
51
        status 200
52
    }
53
}
54

  

Také k dispozici: Unified diff