forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsumerIntegrationTest.java
50 lines (43 loc) · 1.55 KB
/
ConsumerIntegrationTest.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
45
46
47
48
49
50
package mock.contract;
import java.util.List;
import org.junit.AfterClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.springframework.context.ConfigurableApplicationContext;
/**
*
* @author pthomas3
*/
public class ConsumerIntegrationTest {
private static ConfigurableApplicationContext context;
private static Consumer consumer;
@BeforeClass
public static void beforeClass() {
String queueName = "DEMO.INTEGRATION";
context = PaymentService.start(queueName, false);
String paymentServiceUrl = "http://localhost:" + PaymentService.getPort(context);
consumer = new Consumer(paymentServiceUrl, queueName);
}
@Test
public 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");
consumer.waitUntilFirstMessage();
List<Shipment> shipments = consumer.getShipments();
assertEquals(1, shipments.size());
Shipment shipment = shipments.get(0);
assertEquals(payment.getId(), shipment.getPaymentId());
assertEquals("shipped", shipment.getStatus());
}
@AfterClass
public static void afterClass() {
PaymentService.stop(context);
consumer.stopQueueConsumer();
}
}