use of io.confluent.examples.streams.avro.microservices.Product.JUMPERS in project kafka-streams-examples by confluentinc.
the class ValidationsAggregatorServiceTest method shouldAggregateRuleSuccesses.
@Test
public void shouldAggregateRuleSuccesses() throws Exception {
// Given
ordersService = new ValidationsAggregatorService();
orders = asList(new Order(id(0L), 0L, CREATED, UNDERPANTS, 3, 5.00d), new Order(id(1L), 0L, CREATED, JUMPERS, 1, 75.00d));
sendOrders(orders);
ruleResults = asList(new OrderValidation(id(0L), OrderValidationType.FRAUD_CHECK, OrderValidationResult.PASS), new OrderValidation(id(0L), OrderValidationType.ORDER_DETAILS_CHECK, OrderValidationResult.PASS), new OrderValidation(id(0L), OrderValidationType.INVENTORY_CHECK, OrderValidationResult.PASS), new OrderValidation(id(1L), OrderValidationType.FRAUD_CHECK, OrderValidationResult.PASS), new OrderValidation(id(1L), OrderValidationType.ORDER_DETAILS_CHECK, OrderValidationResult.FAIL), new OrderValidation(id(1L), OrderValidationType.INVENTORY_CHECK, OrderValidationResult.PASS));
sendOrderValuations(ruleResults);
// When
ordersService.start(CLUSTER.bootstrapServers());
// Then
List<KeyValue<String, Order>> finalOrders = MicroserviceTestUtils.readKeyValues(Topics.ORDERS, 4, CLUSTER.bootstrapServers());
assertThat(finalOrders.size()).isEqualTo(4);
// And the first order should have been validated but the second should have failed
assertThat(finalOrders.stream().map(kv -> kv.value).collect(Collectors.toList())).contains(new Order(id(0L), 0L, VALIDATED, UNDERPANTS, 3, 5.00d), new Order(id(1L), 0L, FAILED, JUMPERS, 1, 75.00d));
}
Aggregations