Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2d0dd56b

Přidáno uživatelem stepanekp před asi 1 rok

Basic integration test added

Zobrazit rozdíly:

pom.xml
62 62
		<org.junit.jupiter.version>5.9.1</org.junit.jupiter.version>
63 63
		<org.apache.maven.plugins.version>3.0.0-M7</org.apache.maven.plugins.version>
64 64
		<spring-cloud-contract.version>3.0.3</spring-cloud-contract.version>
65
		<skipTests>false</skipTests>
66
		<skipUnitTests>${skipTests}</skipUnitTests>
67
		<skipIntegrationTests>${skipTests}</skipIntegrationTests>
65 68
	</properties>
66 69

  
67 70
	<dependencyManagement>
......
263 266
				<artifactId>maven-surefire-plugin</artifactId>
264 267
				<version>${org.apache.maven.plugins.version}</version>
265 268
				<configuration>
266
					<skipTests>false</skipTests>
269
					<skipTests>${skipUnitTests}</skipTests>
267 270
				</configuration>
268 271
			</plugin>
269 272

  
......
271 274
				<groupId>org.apache.maven.plugins</groupId>
272 275
				<artifactId>maven-failsafe-plugin</artifactId>
273 276
				<version>${org.apache.maven.plugins.version}</version>
277
				<configuration>
278
					<skipTests>${skipIntegrationTests}</skipTests>
279
				</configuration>
274 280
			</plugin>
275 281

  
276 282
			<plugin>
......
283 289
					<baseClassForTests>
284 290
						cz.zcu.fav.kiv.antipatterndetectionapp.v2.controller.BaseTest
285 291
					</baseClassForTests>
292
					<skip>true</skip>
286 293
				</configuration>
287 294
			</plugin>
288 295

  
src/test/java/cz/zcu/fav/kiv/antipatterndetectionapp/controller/detecting/DetectingControllerIT.java
1
package cz.zcu.fav.kiv.antipatterndetectionapp.controller.detecting;
2

  
3
import org.junit.jupiter.api.Test;
4
import org.springframework.beans.factory.annotation.Autowired;
5
import org.springframework.beans.factory.annotation.Value;
6
import org.springframework.boot.test.context.SpringBootTest;
7
import org.springframework.boot.test.web.client.TestRestTemplate;
8
import org.springframework.http.HttpStatus;
9
import org.springframework.http.ResponseEntity;
10

  
11
import static org.assertj.core.api.Assertions.assertThat;
12

  
13
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
14
public class DetectingControllerIT {
15

  
16
    @Autowired
17
    private TestRestTemplate restTemplate;
18

  
19
    @Value("${detecting.service.url}")
20
    private String serviceUrl;
21

  
22
    @Test
23
    public void testExternalServiceAvailabilityOnMetrics() {
24
        ResponseEntity<String> response = restTemplate.getForEntity(serviceUrl + "/metrics", String.class);
25
        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
26
    }
27

  
28
    @Test
29
    public void testExternalServiceAvailabilityOnIndicators() {
30
        ResponseEntity<String> response = restTemplate.getForEntity(serviceUrl + "/indicators", String.class);
31
        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
32
    }
33

  
34
    @Test
35
    public void testExternalServiceAvailabilityOnNonExistEndpoint() {
36
        ResponseEntity<String> response = restTemplate.getForEntity(serviceUrl + "/nonexistingendpoint", String.class);
37
        assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
38
    }
39
}
40

  
41

  
42

  
43

  

Také k dispozici: Unified diff