Updated integration test to ensure system data is returned

This commit is contained in:
Jim Martens 2020-07-11 22:53:15 +02:00
parent cd8fbab752
commit 92b5cb5f22
1 changed files with 6 additions and 10 deletions

View File

@ -1,6 +1,6 @@
package de.twomartens.oparlservice; package de.twomartens.oparlservice;
import de.twomartens.oparlservice.entity.Greeting; import de.twomartens.oparlservice.entity.System;
import de.twomartens.oparlservice.interceptors.RequestTypeInterceptor; import de.twomartens.oparlservice.interceptors.RequestTypeInterceptor;
import de.twomartens.oparlservice.interceptors.TraceIdInterceptor; import de.twomartens.oparlservice.interceptors.TraceIdInterceptor;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -39,24 +39,20 @@ class OParlServiceRestTests {
@Test @Test
void testRestService() { void testRestService() {
ResponseEntity<Greeting> result = restTemplate.getForEntity(getEndpoint(), Greeting.class); ResponseEntity<System> result = restTemplate.getForEntity(getEndpoint(), System.class);
assertThat(result.getStatusCode().is2xxSuccessful()).isTrue(); assertThat(result.getStatusCode().is2xxSuccessful()).isTrue();
assertThat(result.getBody()).isNotNull(); assertThat(result.getBody()).isNotNull();
assertThat(result.getBody().getMessage()).isEqualTo("Hello RestCheck!"); assertThat(result.getBody().getId()).isNotEmpty();
} }
/*
* This method is so complicated because it uses the local-grpc-server configuration for grpc to create
* a correct link for the rest endpoints in the cloud
*/
private String getEndpoint() { private String getEndpoint() {
String hostNameForGrpcServer = "127.0.0.1"; String hostName = "127.0.0.1";
int port = randomServerPort; int port = randomServerPort;
String protocol = "http"; String protocol = "http";
return String.format("%s://%s:%d/greeting?name=RestCheck", return String.format("%s://%s:%d/v1.1/",
protocol, protocol,
hostNameForGrpcServer, hostName,
port); port);
} }
} }