Skip to content

Commit 5e4ad77

Browse files
committed
Apply pull request suggestions
Signed-off-by: Matheus Cruz <[email protected]>
1 parent 77b5db2 commit 5e4ad77

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

sdk-tests/src/test/java/io/dapr/it/testcontainers/pubsub/outbox/ProductWebhookController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
import org.springframework.web.bind.annotation.RequestMapping;
2020
import org.springframework.web.bind.annotation.RestController;
2121

22-
import java.util.ArrayList;
2322
import java.util.List;
23+
import java.util.concurrent.CopyOnWriteArrayList;
2424

2525
@RestController
2626
@RequestMapping("/webhooks/products")
2727
public class ProductWebhookController {
2828

29-
public static final List<CloudEvent<Product>> EVENT_LIST = new ArrayList<>();
29+
public static final List<CloudEvent<Product>> EVENT_LIST = new CopyOnWriteArrayList<>();
3030

3131
@PostMapping("/created")
3232
@Topic(name = "product.created", pubsubName = "pubsub")
33-
public void handleProductCreated(@RequestBody CloudEvent cloudEvent) {
33+
public void handleEvent(@RequestBody CloudEvent cloudEvent) {
3434
System.out.println("Received product.created event: " + cloudEvent.getData());
3535
EVENT_LIST.add(cloudEvent);
3636
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package io.dapr.springboot.examples.producer;
2+
3+
public class OrderDTO {
4+
5+
private String id;
6+
private String item;
7+
private Integer amount;
8+
9+
public OrderDTO() {
10+
}
11+
12+
public OrderDTO(String id, String item, Integer amount) {
13+
this.id = id;
14+
this.item = item;
15+
this.amount = amount;
16+
}
17+
18+
public String getId() {
19+
return id;
20+
}
21+
22+
23+
public String getItem() {
24+
return item;
25+
}
26+
27+
public Integer getAmount() {
28+
return amount;
29+
}
30+
31+
}

spring-boot-examples/producer-app/src/test/java/io/dapr/springboot/examples/producer/ProducerAppIT.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ void cleanUp() {
7575

7676
@Test
7777
void testOrdersOutboxEndpointAndMessaging() {
78+
OrderDTO order = new OrderDTO("outbox-order-123", "Lorem ipsum", 1000);
79+
7880
given().contentType(ContentType.JSON)
79-
.body("{ \"id\": \"outbox-order-123\",\"item\": \"Lorem ipsum\",\"amount\": 1000}")
81+
.body(order)
8082
.when()
8183
.post("/orders/outbox")
8284
.then()
@@ -88,10 +90,10 @@ void testOrdersOutboxEndpointAndMessaging() {
8890
}
8991

9092
@Test
91-
void testOrdersEndpointAndMessaging() throws InterruptedException, IOException {
92-
93+
void testOrdersEndpointAndMessaging() {
94+
OrderDTO order = new OrderDTO("abc-123", "the mars volta LP", 1);
9395
given().contentType(ContentType.JSON)
94-
.body("{ \"id\": \"abc-123\",\"item\": \"the mars volta LP\",\"amount\": 1}")
96+
.body(order)
9597
.when()
9698
.post("/orders")
9799
.then()
@@ -137,7 +139,7 @@ void testOrdersEndpointAndMessaging() throws InterruptedException, IOException {
137139
}
138140

139141
@Test
140-
void testCustomersWorkflows() throws InterruptedException, IOException {
142+
void testCustomersWorkflows() {
141143

142144
given().contentType(ContentType.JSON)
143145
.body("{\"customerName\": \"salaboy\"}")

0 commit comments

Comments
 (0)