|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
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.TraceIdInterceptor; |
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
@ -39,24 +39,20 @@ class OParlServiceRestTests {
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
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.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() { |
|
|
|
|
String hostNameForGrpcServer = "127.0.0.1"; |
|
|
|
|
String hostName = "127.0.0.1"; |
|
|
|
|
int port = randomServerPort; |
|
|
|
|
String protocol = "http"; |
|
|
|
|
|
|
|
|
|
return String.format("%s://%s:%d/greeting?name=RestCheck", |
|
|
|
|
return String.format("%s://%s:%d/v1.1/", |
|
|
|
|
protocol, |
|
|
|
|
hostNameForGrpcServer, |
|
|
|
|
hostName, |
|
|
|
|
port); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|