|
1 | 1 | package payment.consumer;
|
2 | 2 |
|
3 |
| -import com.intuit.karate.netty.FeatureServer; |
| 3 | +import com.intuit.karate.core.MockServer; |
4 | 4 | import java.io.File;
|
5 |
| -import org.junit.AfterClass; |
6 |
| -import org.junit.Test; |
7 |
| -import static org.junit.Assert.*; |
8 |
| -import org.junit.BeforeClass; |
| 5 | +import org.junit.jupiter.api.AfterAll; |
| 6 | +import static org.junit.jupiter.api.Assertions.*; |
| 7 | +import org.junit.jupiter.api.BeforeAll; |
| 8 | +import org.junit.jupiter.api.Test; |
9 | 9 | import payment.producer.Payment;
|
10 | 10 |
|
11 | 11 | /**
|
12 | 12 | *
|
13 | 13 | * @author pthomas3
|
14 | 14 | */
|
15 |
| -public class ConsumerIntegrationAgainstMockTest { |
16 |
| - |
17 |
| - private static FeatureServer server; |
18 |
| - private static Consumer consumer; |
19 |
| - |
20 |
| - @BeforeClass |
21 |
| - public static void beforeClass() { |
| 15 | +class ConsumerIntegrationAgainstMockTest { |
| 16 | + |
| 17 | + static MockServer server; |
| 18 | + static Consumer consumer; |
| 19 | + |
| 20 | + @BeforeAll |
| 21 | + static void beforeAll() { |
22 | 22 | File file = new File("../payment-producer/src/test/java/payment/producer/mock/payment-mock.feature");
|
23 |
| - server = FeatureServer.start(file, 0, false, null); |
| 23 | + server = MockServer.feature(file).http(0).build(); |
24 | 24 | String paymentServiceUrl = "http://localhost:" + server.getPort();
|
25 |
| - consumer = new Consumer(paymentServiceUrl); |
26 |
| - } |
27 |
| - |
| 25 | + consumer = new Consumer(paymentServiceUrl); |
| 26 | + } |
| 27 | + |
28 | 28 | @Test
|
29 |
| - public void testPaymentCreate() throws Exception { |
| 29 | + void testPaymentCreate() throws Exception { |
30 | 30 | Payment payment = new Payment();
|
31 | 31 | payment.setAmount(5.67);
|
32 | 32 | payment.setDescription("test one");
|
33 | 33 | payment = consumer.create(payment);
|
34 | 34 | assertTrue(payment.getId() > 0);
|
35 | 35 | assertEquals(payment.getAmount(), 5.67, 0);
|
36 |
| - assertEquals(payment.getDescription(), "test one"); |
| 36 | + assertEquals(payment.getDescription(), "test one"); |
37 | 37 | }
|
38 |
| - |
39 |
| - @AfterClass |
40 |
| - public static void afterClass() { |
| 38 | + |
| 39 | + @AfterAll |
| 40 | + static void afterAll() { |
41 | 41 | server.stop();
|
42 |
| - } |
43 |
| - |
| 42 | + } |
| 43 | + |
44 | 44 | }
|
0 commit comments