forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsumerIntegrationAgainstMockTest.java
executable file
·44 lines (37 loc) · 1.2 KB
/
ConsumerIntegrationAgainstMockTest.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
36
37
38
39
40
41
42
43
44
package payment.consumer;
import com.intuit.karate.core.MockServer;
import java.io.File;
import org.junit.jupiter.api.AfterAll;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import payment.producer.Payment;
/**
*
* @author pthomas3
*/
class ConsumerIntegrationAgainstMockTest {
static MockServer server;
static Consumer consumer;
@BeforeAll
static void beforeAll() {
File file = new File("../payment-producer/src/test/java/payment/producer/mock/payment-mock.feature");
server = MockServer.feature(file).http(0).build();
String paymentServiceUrl = "http://localhost:" + server.getPort();
consumer = new Consumer(paymentServiceUrl);
}
@Test
void testPaymentCreate() throws Exception {
Payment payment = new Payment();
payment.setAmount(5.67);
payment.setDescription("test one");
payment = consumer.create(payment);
assertTrue(payment.getId() > 0);
assertEquals(payment.getAmount(), 5.67, 0);
assertEquals(payment.getDescription(), "test one");
}
@AfterAll
static void afterAll() {
server.stop();
}
}