-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
OrderResourceContractTests.java
35 lines (26 loc) · 1.26 KB
/
OrderResourceContractTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.acme.order.api;
import static org.junit.jupiter.api.Assertions.*;
import org.acme.order.BaseTest;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
import io.github.microcks.testcontainers.MicrocksContainer;
import io.github.microcks.testcontainers.model.TestRequest;
import io.github.microcks.testcontainers.model.TestResult;
import io.github.microcks.testcontainers.model.TestRunnerType;
@QuarkusTest
public class OrderResourceContractTests extends BaseTest {
@Test
void testOpenAPIContract() throws Exception {
// Ask for an Open API conformance to be launched.
TestRequest testRequest = new TestRequest.Builder()
.serviceId("Order Service API:0.1.0")
.runnerType(TestRunnerType.OPEN_API_SCHEMA.name())
.testEndpoint("http://host.testcontainers.internal:" + quarkusHttpPort + "/api")
.build();
TestResult testResult = MicrocksContainer.testEndpoint(microcksContainerUrl, testRequest);
// You may inspect complete response object with following:
//System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(testResult));
assertTrue(testResult.isSuccess());
assertEquals(1, testResult.getTestCaseResults().size());
}
}